Click to See Complete Forum and Search --> : expire a cookie?


mrhalloran
01-31-2002, 01:01 PM
How do you make a cookie expire?
Someone on the board suggested this once:
setcookie("Uname");
but it doesn't seem to work. Is there a better command? Can I just set an expiration date in the past or something like that? I want a sure fire way so that:
if (isset($Uname)) {
will return false.

Thanks,
Mark

bacil
01-31-2002, 01:49 PM
setcookie ("TestCookie", $value,time()+3600);
this cookie will expire in 3600 secs

or

setcookie ("TestCookie","") will unset cookie

Ivan

mrhalloran
01-31-2002, 02:03 PM
Thanks you. I didn't post this in Install Help by the way. Phpbuilder is acting up.
Thanks for the reply.
shouldn't setcookie ("TestCookie","")
be the same as setcookie ("TestCookie") though, which is what I have?

Anon
01-31-2002, 06:36 PM
This works, deleting the cookie!

setcookie ("TestCookie");

Remember that the actual status of the cookies is visible for your scripts AFTER the next http-request from the client, not yet in your script which unsets the cookie.
Best regards,


King Louie