Return to Snippet

Revision: 31402
at September 4, 2010 03:38 by jonkemp


Initial Code
function createCookie(name,value,path) {
	var expires = "";
	var date = new Date();
	var midnight = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59);
	expires = "; expires=" + midnight.toGMTString();
	if (!path) {
		path = "/";
	}
	document.cookie = name + "=" + value + expires + "; path=" + path;
}

Initial URL

                                

Initial Description
Set a cookie that expires at midnight.

Initial Title
JavaScript Set Cookie Midnight Expiration

Initial Tags
javascript

Initial Language
JavaScript