Brad45
Brad45

Reputation: 199

Cookie deletion issues when using IE

Okay, my site is written in PHP. I'm having problems with IE sometimes not deleting the cookies. Here's my log out code.

setcookie("user", "", time() - 50000000);

setcookie("pass", "", time() - 50000000);

header("Location: index.php");

This works great in Firefox, Chrome, etc. But IE sometimes won't delete the cookies?

My login when setting cookies looks like this:

setcookie("user", $result['Handle'], time() + 50000000);

setcookie("pass", $pass, time() + 50000000);

header("Location: news.php");

I just don't understand why it will clear it most of the time, but gets stuck other times.

Upvotes: 1

Views: 272

Answers (1)

Mark Foster
Mark Foster

Reputation: 484

Be careful you are not setting cookie at different directory levels. This will effectively create two cookies for the same domain but with one set for a sub-directory/path. I.e. www.example.com vs. www.example.com/mypath. It is possible you set the cookie for a sub-path in addition to the root and are now deleting only the cookie for the sub-directory so the root cookie remains. I don't believe this would be an IE specific behavior though.

Upvotes: 1

Related Questions