1.

Solve : Javascript Set cookie?

Answer»

I'm TRYING to set cookies. It just works when i pass Name & Value. It doesn't when i'm PASSING expiry, path and domain. Please see the code as below and let me know what is wrong in there:

function SetCookie(COOKIENAME,cookieValue,nDays,path,domain) {
var today = NEW Date();
var expire = new Date();
if (nDays==null || nDays==0) nDays=1;
expire.setTime(today.getTime() + 3600000*24*nDays);
document.cookie = cookieName+"="+escape(cookieValue)+";expires="+expire.toGMTString()+";path="+path+";domain="+domain;
}

var Fdays=2;
SetCookie('openedDivID',divID,Fdays,'/','www.myDomain.com');


I would APPRECIATE your response.Check out www.quackit.com

and find the page with it, it has a pretty good tutorial.Or here: http://www.w3schools.com/JS/js_cookies.asp



Discussion

No Comment Found