I tried my website on local host with Safary, chrome, firefox, and opera and appears that when I close the browser it remove the session too. But when I tried on Chrome, it still there. why is that so ?
-
2The session validity time depends on your server settings and also depends on when browsers delete the session cookies (it may be on exit, after cookie expires / on session ends) – fardjad Aug 09 '12 at 06:40
-
Check this following link may be this will answer your doubt. If you like this post vote up for this post. http://stackoverflow.com/a/1236583/1567851 – SidPen Aug 09 '12 at 06:48
-
1/me facepalm at all the upvotes to people trying to give lecture about session cookie. This weird behavior is caused by the "Continue where I left off" startup option in Chrome. Apparently you can do the same with Firefox since quite some time ago, and Chrome just adopted this "feature" very recently. I just learned about this moments ago. See http://code.google.com/p/chromium/issues/detail?id=128513 – sayap Aug 17 '12 at 08:51
2 Answers
Session is basically a cookie stored by your browser.
Cookie has an age. After they expire browsers usually discard them and/or servers disregard them.
There also special types of cookies that browsers are required to remove after they are closed.
Since your sessions disappears after closing Safary and Firefox, it looks like you have the second type of cookies. So, are you sure you've closed your Chrome browser? May be you have some window left in another virtual desktop or something...

- 9,152
- 8
- 37
- 45
Sessions are stored by default in cookies.
A cookie is a small value stored in the browser, and they always have an expiry date. If the expiry date is in the past, the cookie is destroyed immediately. If the cookie has an expiry date in the future, it is kept and used until that date, at which point it is destroyed. There is also a special "date" that can be used which tells the browser to consider the cookie valid as long as the browser is open. Typically the browser will destroy those cookies when you click the X
to close the application.
Keep in mind that browsers can be configured to never delete cookies (even expired ones), to delete cookies every time the application is closed, even if the cookie is still valid, or even to not accept cookies at all.

- 4,583
- 2
- 37
- 50