1

Using PHP 5.3.10 I'm setting a few cookies on login. However, no matter the browser, the url, or the additional arguments I try setting, the cookies are always gone when I close the browser and return.

In php:

setcookie( $key, $value, time()+2592000, '/' );

I've tried setting the domain, secure/http arguments but they don't seem to impact this.

I've tried this for Firefox 12, Safari, Chrome. None are set to clear cookies on exit/reboot.

An example of the http header:

Set-Cookie: authentication_key=24...b6; expires=Thu, 31-May-2012 22:49:26 GMT; path=/

When I close the browser and return the exact same address (no changes in http/s or www) the cookies are gone.

3
  • its a long shot, but if your server sends a bogus Date: header, it can really screw stuff like this up.
    – goat
    May 1, 2012 at 23:11
  • how are you testing that the cookie is gone? May 1, 2012 at 23:21
  • In all browsers I open the inspector which shows the cookies for the current domain.
    – helion3
    May 1, 2012 at 23:44

1 Answer 1

0

Even if you set them not to expire, the browser or operating system can still delete them for a number of reasons, the most common a user setting.

3
  • This is happening for all users, not just me.
    – helion3
    May 1, 2012 at 22:59
  • Weird. Also it is a good idea to use sessions for login systems instead of cookies, they are more secure
    – Ethan H
    May 1, 2012 at 23:01
  • We do, this for people who want to be re-authenticated when they return.
    – helion3
    May 1, 2012 at 23:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.