I search Google but found entire functions to get cookie value. Isn't there one line statement to retrieve cookie value in javascript?
A:
There isn't a "single statement". One possibility: document.cookie.
function getCookie(c_name)
{
if (document.cookie.length>0)
{
c_start=document.cookie.indexOf(c_name + "=");
if (c_start!=-1)
{
c_start=c_start + c_name.length+1;
c_end=document.cookie.indexOf(";",c_start);
if (c_end==-1) c_end=document.cookie.length;
return unescape(document.cookie.substring(c_start,c_end));
}
}
return "";
}
jldupont
2009-12-18 13:13:13
That is the link I meant. I don't want to include those functions.
RPK
2009-12-18 13:15:46
understood.Any specific reasons?
ram
2009-12-18 13:19:36
+1
A:
You could use a javascript library, e.g. jQuery in addition with a plugin: http://plugins.jquery.com/project/cookie
Demo page: http://stilbuero.de/jquery/cookie/
The MYYN
2009-12-18 13:14:27
A:
im sure there is a simplier way to get a cookie?
like all u gotta do to set one is like
document.cookie "cookiename=cookievalue";
there must be a way to read it as simple like
var cvalue = getcookie "cookiename"
Owen
2010-07-30 13:50:58