I'm developing a web application using a cookie to store session information. I've manually deleted the session cookies because I'm working on another part of the code where I don't want a login session. However, after a couple reloads of the page, the session cookie mysteriously reappears, including an earlier cookie that I had only set once for testing purposes, then deleted and never used again.
I keep manually deleting the cookies in question, but still, when I reload the page after a while, the cookies are back. I've double-checked my code and I am positive I'm not setting those cookies anywhere. My code is all in one file at the moment, and I'm not including anything, so there's no possibility that I'm overlooking something.
My code is in PHP and used the setcookie() call when I initially created those cookies.
I've not set an expiry date on the cookies. Using Safari 4 Beta and the GlimmerBlocker proxy.
What's the explanation for this weird behaviour?
-
Is it only Safari which is showing this strangeness, is Firefox also doing something similar?
TStamper : this should have been a comment to his question not an answerNiels Heidenreich : Can't test right now because working on the code, but you're of course right, should have tested this first. From the answers I got now it looks to be a Safari-specific problem, though. -
Try this, it should remove all of your session cookies:
session_start(); // Unset all of the session variables. $_SESSION = array(); // If it's desired to kill the session, also delete the session cookie. // Note: This will destroy the session, and not just the session data! if (isset($_COOKIE[session_name()])) { setcookie(session_name(), '', time()-42000, '/'); } // Finally, destroy the session. session_destroy();
Niels Heidenreich : Thanks, but I'm not using PHP's session handling functions; I'm just using setcookie(). I've tried to force-delete the cookies by setting them to an empty string and with an expiration date long in the past (like in the code you posted above), but it doesn't help. It's weird. -
There are known problems with certain browsers cookie handling.
See the following paper: iSEC Cleaning Up After Cookies
Also see this discussion on Apple.com regarding the case of the reappearing cookie.
-
What version of the OS are you using? What other apps are you using at the same time? These issues are generally due to apps stomping on the cookie storage file (~/Library/Cookies/Cookies.plist) one after another.
0 comments:
Post a Comment