WebWoman Search

Setting Cookies with JavaScript
(Using the cookie library.)

The syntax for SetCookie is:

   SetCookie(name,value,expires,path,domain,secure)

You must set name and value, the others are optional.

The code I used here to set a cookie called "nickname" is:

   if (GetCookie("nickname") == null) {
      var zNickname = prompt("What\'s your nickname?", "")
      var SetCookie("nickname", zNickname, expires)
   }

To set a cookie with no expiration date:

 	SetCookie ("noExpDate", "this one expires when the session ends")

To set a cookie that can be retrieved from anywhere in the domain:

   SetCookie ("anyDomain", "This cookie will work anywhere in this domain",null,"/");

View your cookie file and see if you can find the above cookies listed.

WebWoman™ - Your web development superhero!      Phone: (843) 821-1466