get_cookie() Function

How to retrive the cookies in javascript?
(or) get_cookie() Function?


The get_cookie() function is used to retrive the cookies in javascript.
function get_cookie(c_name)
if (document.cookie.length>0)//checks for the availability of cookie name
c_start=document.cookie.indexOf(c_name + "=");
if (c_start!=-1)
c_start=c_start + c_name.length+1;
if (c_end==-1) c_end=document.cookie.length;
return unescape(document.cookie.substring(c_start,c_end));//returns the cookie after decoding
return "";
The above function gets and retrive the name of the cookies with its value along with the expiry date of the cookie.

Ask Questions

Ask Question