3

How do I prevent cookies from expiring when my browser is closed?

0

3 Answers 3

3

You can't. Those cookies are set that way for security. If you are asking about how to set a cookie's expiration date on your own site, then see these PHP and Javascript methods.

2
  • By "you can't" do you really mean "you shouldn't"? Or do you mean "it's impossible"?
    – user541686
    Sep 13, 2011 at 4:53
  • 1
    I mean that some sites employ not only timeouts for validating cookies, but a hashed value that also has a server-side timeout value that will no longer authenticate no matter what the local timeout value is.
    – jsejcksn
    Sep 15, 2011 at 21:51
3

Use a cookie editor?

3
  • Awww... it doesn't seem to work with my version of Chromium. :( But +1 thanks anyway, I'll give it a try later if I can.
    – user541686
    Sep 13, 2011 at 4:54
  • While the above link still works more than ten years later it looks as if EditThisCookie has had a rather bad track record so maybe use Cookie-Editor instead. May 19, 2023 at 19:18
  • If you are running Chrome you might not need an extension in the first place, because – at least nowadays – it has an integrated cookie editor in Chrome DevTools which works quite nicely. May 19, 2023 at 19:41
0

You can try using the Cookies pane to change the Expire attribute from Session to some arbitrary date in the future. That effectively converts the session cookies to persistent cookies.

You mileage may vary though because as correctly mentioned the server-side timeout is authorative.

It seems though as there may be cases where the server-side session timeout is actually longer than the Expires attribute of the corresponding cookie.

I just had a case where a website foobar using authentication via a single sign-on service required a re-login as soon as the last browser window of the website was closed. Adding an Expires attribute to the session cookie kept the session alive even after restarting the browser.

Alternatively adding an Expires attribute to the authentication cookie of the single sign-on service requires a re-login on the website foobar but avoids having to re-enter the credentials at the single sign-on service.

Manually editing cookie attributes is obviously not very user-friendly, so wrapping the procedure into some browser extension or userscript seems meaningful.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .