Strange unset cookie problem

Posted by neobie on Stack Overflow See other posts from Stack Overflow or by neobie
Published on 2010-05-07T02:41:44Z Indexed on 2010/05/07 2:48 UTC
Read the original article Hit count: 305

Filed under:
|
|

Hi there, I have a strange problem to clear Cookie via PHP.

Lets say if I have a domain neobie.net I store "remember user login" cookie name as "USER_INFO" which contains string to identify user login in the next time of revisit.

now using firefox, I saw that I have 2 cookies USER_INFO with domain "www.neobie.net" and ".neobie.net" with expiration date of 1 week later.

I wrote a logout.php script, which clear the cookie of different domain (.neobie.net, www.neobie.net, neobie.net) to ensure that USER_INFO cookie is completely cleared for different domain.

Now is the problem. The user isn't able to clear the cookie when user visit logout.php

I found out that, I have to manually delete the cookie with domain "www.neobie.net", leaving the ".neobie.net " intact, then only the cookie can be cleared.

So, I have to make the php script to setcookie USER_INFO on ".neobie.net", and prevent it to set cookie on "www.neobie.net" to make the logout.php script work.

But I don't understand why I couldn't clear the cookie for "www.neobie.net" (with leading www. , tested on firefox and chrome)

© Stack Overflow or respective owner

Related posts about php

Related posts about cookie