how to delete a cookie?

D

Daniel Vieira

I need to delete one cookie without delete the session.
How am I supposed to know wich one is the right cookie?

by the way, it will always be the last one.
Can I order it by date?
how?

Thanks
 
E

Erwin Moller

I need to delete one cookie without delete the session.

What session?
A session with the server, to maintain state?

These can have any name.
For example: in PHP the default name is PHPSESSID.

How am I supposed to know wich one is the right cookie?

Cookies can have any (legal) name.
So I doubt anyone can help you if you are not more specific.
by the way, it will always be the last one.
Can I order it by date?
how?

If you are using Firefox, install an add-on called web-developer.
You can get it here:
http://chrispederick.com/work/web-developer/

You are welcome.

Erwin Moller
 
D

Dr.Kral

I need to delete one cookie without delete the session.
How am I supposed to know wich one is the right cookie?

If you are talking about your own computer, then in the browser where the
cookie exists use whatever cookie manager function provided to delete it
manually. It may not actually disappear until you close the browser
however. Note that each browser has it own set of cookies.

If you are talking about another's computer then (re)write the cookie with
an expiration date set to 'now' or before. This may be done with the same
page or another from the same site. When the page is closed or the browser
closed, the cookie will vanish. (Of course, how you get other people to
reload such a page is a different question and again must be done in each
browser.)

As was mention in another reply, cookies have names and you defined the
name when the cookie was created.
 
T

Thomas 'PointedEars' Lahn

If you are talking about another's computer then (re)write the cookie with
an expiration date set to 'now' or before.

The GMT date string representation of epoch appears to be the most reliable
and most easily computed invalid value to cause instantaneous non-HTTP-only
cookie deletion (it MUST be "GMT" per the cookie protocols – although recent
UAs appear to accept "GMT+0000 (UTC)" as well –, which means you SHOULD use
Date.prototype.toUTCString()).

Setting the expiration date to now is possible to only make the cookie a
session cookie, deleted not before the browser session ends (i.e., when all
browser windows are closed). Setting it to the string value 'now' has no
effect at all, of course. (But perhaps you meant something else. Also,
there is currently an error in the MDN documentation of document.cookie when
it says that you can delete a cookie by setting its expiration time to zero.
Instead, you need to set the time _value_, of Date instance that generates
the GMT date string representation used, to 0; i.e. you should use epoch,
AISB.)
This may be done with the same page or another from the same site. When
the page is closed or the browser closed, the cookie will vanish. (Of
course, how you get other people to reload such a page is a different
question and again must be done in each browser.)

Reloading the document is unnecessary to delete a cookie using *client-side*
scripting (which is what discussions in this newsgroup are about, unless
stated otherwise). Just assign an appropriate value to the document.cookie
property.

Please get yourself a real name.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,067
Latest member
HunterTere

Latest Threads

Top