Click to See Complete Forum and Search --> : Deleting Cookies...


duartebr
03-21-2003, 02:29 PM
Hellow!

I need to delete a cookie.

How?

Thanks!

Nedals
03-21-2003, 02:36 PM
Set the cookie with....

.... expires=Wed, 01-Jan-2003 00:00:00 GMT

duartebr
03-21-2003, 02:50 PM
OK!

But i need manualy delete.

For example

"mycookie.Delete" OR "mycookie = null"...

Whats?


Originally posted by nedals
Set the cookie with....

.... expires=Wed, 01-Jan-2003 00:00:00 GMT

Nedals
03-21-2003, 03:13 PM
This is the ASP forum, so I 'assumed' you wanted to do something server-side which, of course, cannot be done manually. If you want to delete a cookie manually using the browser then you need a button and a little javascript.

function deletecookie() {
document.cookie = "yourCookieName='none'; expires=Wed, 01-Jan-2003 00:00:00 GMT";
}
Is that what you meant?

SeGamysa
03-21-2003, 03:23 PM
is this cookie on your computer or some oen elses?
that needs to be deleted

duartebr
03-21-2003, 03:32 PM
Ok,
nut now when i create the cookie with last name there isn't more.

Help-me please.

Originally posted by nedals
This is the ASP forum, so I 'assumed' you wanted to do something server-side which, of course, cannot be done manually. If you want to delete a cookie manually using the browser then you need a button and a little javascript.

function deletecookie() {
document.cookie = "yourCookieName='none'; expires=Wed, 01-Jan-2003 00:00:00 GMT";
}
Is that what you meant?

Nedals
03-21-2003, 08:06 PM
nut now when i create the cookie with last name there isn't more. I'm having a little difficulty understanding your English. I gather it's not your native language, so I will try to understand what you need.

If you create a cookie on a site, that will be the only one that exists FOR YOU. (there maybe others on the client computer but you will never see them). The only time there are more, is if YOU put them there. To delete any cookie that YOU put there, you send a cookie, WITH THE SAME NAME and with an expire date that's before today. I used Jan 01, 2003 in my examples.

Am I helping?

Nedals
03-22-2003, 12:02 PM
Dave...
Couple of minor questions (always learning)
function delCookie(name) {
exp = new Date();
exp.setTime(exp.getTime() - (24*60*60*1000));
var cval = getCookie(name);
cval = (cval == null) ? "" : cval;
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}Help me understand why the complexity. In the above you also need to include the 'getCookie()' function.
My example (earlier post) does the same thing, I think, but in one line of code. Is there a requirment to include the value of the cookie. I was under the impression that only the 'name' is required to delete (or change the value of) a cookie.
Not being critical, just asking. :)