Creating Cookies
Creating cookies is amazingly straightforward and simple. Here I have created a little demo that shows how easy it is to create a cookie in JavaScript. Here is the JavaScript function that creates a cookie with the user's name and an expiration date in the year 2050:

function setCookie()
{
   var the_name = prompt("What's your name?","");
   var the_cookie = "wm_javascript=username:" + escape(the_name);
   var the_date = new Date("December 31, 2050");
   var the_cookie_date = the_date.toGMTString();
   the_cookie = the_cookie + ";expires=" + the_cookie_date;
   document.cookie = the_cookie;
}

To call this function, we simply make it the onClick action of an HTML hyperlink or form button. Try out the demo.

For information about the specific syntax of cookies, how a website creates and accesses them: http://home.netscape.com/newsref/std/cookie_spec.html.