Function explained:
Take the cookiename as parameter (cname).
Create a variable (name) with the text to search for (cname + "=").
Decode the cookie string, to handle cookies with special characters, e.g. '$'
Split document.cookie on semicolons into an array called ca (ca = decodedCookie.split(';')).
Loop through the ca array (i = 0; i < ca.length; i++), and read out each value c = ca[i]).
If the cookie is found (c.indexOf(name) == 0), return the value of the cookie (c.substring(name.length, c.length).
If the cookie is not found, return "".
İşlev açıklaması:
Çerez adını parametre olarak al (cname).
Aranacak metni içeren bir değişken (name) oluştur (cname + "=").
Özel karakterler içeren çerezleri (örneğin '$') işlemek için çerez dizesini çöz
Noktalı virgüllerdeki document.cookie'yi ca adlı bir diziye böl (ca = decodedCookie.split(';')).
ca dizisinde döngü oluştur (i = 0; i < ca.length; i++) ve her değeri oku c = ca[i]).
Çerez bulunursa (c.indexOf(name) == 0), çerezin değerini döndür (c.substring(name.length, c.length).
Çerez bulunmazsa, "" döndür.