Eat that cookie!

lomn75

Purple Ace
Joined
Jun 26, 2000
Messages
6,613
I'm working with a script that includes a remember-login cookie. However, I'm having trouble killing the cookie.

Under normal conditions the cookie contains a hash plus expiry of two weeks later:
Code:
setcookie(COOKIE_NAME, md5($login_string), time() + 3600*24*14);

Here's the relevant logout code
Code:
ob_start();
setcookie(COOKIE_NAME, "", 10); // timeout in 1970
unset($_COOKIE[COOKIE_NAME]);
ob_end_flush();
COOKIE_NAME is a correctly-defined constant. I'm really not sure if the unset() does anything directly associated with the cookie, but figured it didn't hurt.

Anyway, as for the problem: Works fine in IE/Win and FF/Win. Doesn't work with Safari/Mac. Unfortunately, I don't have a Mac box to test on.

Any thoughts?
 
afailk setting the cookie value to "" clears it, assuming it has the same path and secure args if they were used initially.

as far as macx, ugh. i don't know what to suggest. i also don't have a mac (i despise them ;), but that's not what this thread is about) but i'd at least like to know that my site works on them.
 
Bump...
Best I can tell, my syntax matches the above.
Also, this code is fubar on SourceForge servers with FF and IE (windows), so it's apparently not just a browser issue.

(The output buffering is enabled because content is generated before the cookie is reset to "")
 
Back
Top