Create cookies from javascript

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

2 thoughts on “Create cookies from javascript

  1. Thanks for any other great article. Where else may anybody get that kind of info in such a perfect way of writing? I have a presentation next week, and I am on the search for such information.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s