Click to See Complete Forum and Search --> : problem deleting cookie through onLoad


brokeDUstudent
09-06-2003, 12:03 AM
Hey hows it going,
I've been trying for about atleast an hour now to get this cookie to delete.. I've tried several different methods, I'm not sure why it's not working. Here's the javascript code im using:

var today = new Date();
var expired = new Date(today.getTime() - 28 * 24 * 60 * 60 * 1000); // less 28 days
var dootie = document.cookie;

function deleteCookie(name){
document.cookie=name + "=null; expires=" + expired.toGMTString();
dootie = document.cookie;
alert("cookie deleted.");
}

when the page loads, this is in the body tag: onLoad="deleteCookie('id')"

Thanks for any ideas, I could really use them..

brokeDUstudent
09-06-2003, 01:24 AM
Here's the new code..

function deleteCookie(name){
var today = new Date();
today.setTime (today.getTime() - 28 * 24 * 60 * 60 * 1000); // less 28 days
var dootie = document.cookie;
var path = "/v2/";
var domain = ".bnosdesign.com";
var secure = "0";
document.cookie=name + "=null; expires=" + today.toGMTString() + "; path=" + path + "; domain=" + domain;
dootie = document.cookie;
alert("cookie deleted.");
}

and I call this in the body tag onLoad="deleteCookie('id')"

thanks anyway for looking, have a good one