Return to Snippet

Revision: 31397
at September 4, 2010 02:16 by jonkemp


Initial Code
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=/";
}

Initial URL
http://www.quirksmode.org/js/cookies.html

Initial Description
The cookie expires the number of days from the time it is set.

Initial Title
JavaScript Set Cookie

Initial Tags
javascript

Initial Language
JavaScript