Showing posts with label Function to get Cookies values. Show all posts
Showing posts with label Function to get Cookies values. Show all posts

Wednesday, October 6, 2010

Javascript: Function to get Cookies values

function getCookiesValue(objCkNm)
{
var beginindex, endindex, result, num;
num = objCkNm.length;
beginindex=document.cookie.indexOf(objCkNm) + num +1 ;
endindex=beginindex;
//while we haven't hit ";" and it's not end of cookie
while (document.cookie.charAt(endindex)!=";" && endindex <= document.cookie.length)
endindex++

//result contains "JavaScript Kit"
result=document.cookie.substring(beginindex,endindex)
return result;
}