[Javascript] Newbie question
Shawn Milo
Shawn at Milochik.com
Thu Dec 1 13:07:55 CST 2005
Sure, here you go.
First of all, I have a line in the customizePage() function to set the
cookie:
createCookie('rbuc',rbuc,30)
//(Set cookie rbuc to the current value of the rbuc variable, to expire in
30 days)
Then these, which I found online:
//following cookie functions from
http://www.quirksmode.org/js/cookies.html
function createCookie(name,value,days)
{
if (days)
{
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name)
{
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++)
{
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,
c.length);
}
return null;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20051201/2ecfd054/attachment.htm>
More information about the Javascript
mailing list