P
Phil Powell
// OBTAINED FROM http://www.javascripter.net/faq/settinga.htm
// NOTE THAT IF YOU SET days TO -1 THE COOKIE WILL BE SET TO YESTERDAY
AND THUS EXPIRE
function setCookie(name, value, days, docObj) {
var today = new Date();
var expire = new Date();
if (days == null || isNaN(days) || days == 0) days = 1;
if (days >= 1 || days < 0) expire.setTime(today.getTime() + 3600000 *
24 * days);
docObj.cookie = name + '=' + escape(value) + ';expires=' +
expire.toGMTString();
}
I am using this Javascript function to set a cookie to expire, and yet,
for some reason, when i set it to expire:
setCookie('my_cookie', '', -1, this.document);
It sets the cookie named "my_cookie" to the literal '' which does not
actually expire but still exist with the value of '', even upon page
reload!
I'm using Netscape 7.1 and IE 5.1 and happens on both
I want the cookie to be completely destroyed upon page reload, what
must I do?
Thanx
Phil
// NOTE THAT IF YOU SET days TO -1 THE COOKIE WILL BE SET TO YESTERDAY
AND THUS EXPIRE
function setCookie(name, value, days, docObj) {
var today = new Date();
var expire = new Date();
if (days == null || isNaN(days) || days == 0) days = 1;
if (days >= 1 || days < 0) expire.setTime(today.getTime() + 3600000 *
24 * days);
docObj.cookie = name + '=' + escape(value) + ';expires=' +
expire.toGMTString();
}
I am using this Javascript function to set a cookie to expire, and yet,
for some reason, when i set it to expire:
setCookie('my_cookie', '', -1, this.document);
It sets the cookie named "my_cookie" to the literal '' which does not
actually expire but still exist with the value of '', even upon page
reload!
I'm using Netscape 7.1 and IE 5.1 and happens on both
I want the cookie to be completely destroyed upon page reload, what
must I do?
Thanx
Phil