session expiration

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi Folk

I have a site where I set a session cookie that expires in 1000 days.

As part of my script,. I create a $_SESSION["variable"].

Now, I am wondering, if the user closes their browser window and, for  
example, come back to the site next week, will the session variable still be  

Thank you

- Nicolaas  

Re: session expiration

absolutely expired~

Re: session expiration

Depends on his cookies setting and you Session configuration (if you
session uses cookies or the query string).

If user doesn't delete cookies when his browser closes (and your
Session uses cookies) then I guess the Session would be fine.

One more thing, Session data is (generally) saved in a file under /tmp
if files there get deleted, Session variable will be gone.

Re: session expiration

Meiao wrote:

Quoted text here. Click to load it

No, not under standard circumstances.

The COOKIE will be fine, true,  but the sessiondata will be  
garbaged-collected or time-out by timestamp.
So PHP cannot restore the session and will start a new session.

PHP will clean up old sessionfiles, and PHP decides when a file is old by  
using php.ini settings.
I think default is half an hour.

Quoted text here. Click to load it

Even when they file was for some reason NOT garbage collected, PHP checks  
the timestamp, and decides it is old, and will not use it.
(This can happen if you disable garbage collection by making the chances for  
it happening extremely small in php.ini)

To make the original posters scenario work, you need to make sessions last  
for weeks, or months or whatever.
Not really a good thing to do, resourcewise. :-)

Erwin Moller

Site Timeline