What is the scope of the session
variable $_SESSION['']
? If I have a bunch of webpage surveys strung together, one after the other, will a session variable
expire after a certain amount of time or will it exist as long as you don't close the browser? What happens if you hibernate your computer?
I seemed to have lost a session variable after hibernating and I'm not sure if that's the issue or if there is some other problem.
The session as a whole (not just single variables) can be continued or lost for many reasons.
In the default configuration, the session is meant to be "lost" when the browser closes because the browser will remove the cookie identifying the session. It is still somewhere on the server until the session garbage collection deletes it. Because of that, a browser that is idle for a long time might still loose it's session because PHP will remove ones that haven't been used lately.
Check the configuration. In particular, you might want to adjust "session.gc_maxlifetime" and "session.cookie_lifetime" to your needs if you need to keep your sessions around longer.
Session variables don't expire. Sessions expire subject to session_gc.maxlifetime
and other configuration options.
Sessions are not tied to the browser. However, the browser might choose not send the required information to the server for the server to resume an earlier session. This typically happens when the browser treats all cookies as session cookies.
The term session cookie in this context does not mean a cookie that holds a session identifier or session variables. Rather it's a cookie that is gone as soon as the browser is closed (i.e. the users session in front of the browser ends).
Depends on:
0
should mean 'until the browser closes', but firefox / mozilla tend to view it (due to their 'restore session' functionality) as 'forever' (which is IMHO a security concern so you should regenerate your id on receiving an empty session array). So: user-agent dependant.session.gc_maxlifetime
settings are ignored due to to another server-wide setting.So, in other words, your session still lives if your UA has decided to keep the cookie, and no process has decided to remove the data. Which requires you to know the settings of both UA and your server.