There are two components to a session variable.
First is the session ID cookie on the browser. By default, that cookie is set to last until the browser is shut down.
However, a matching session store (by default on the server's filesystem) must also exist. Without it, the session actually still works, but all the variables in it are missing.
PHP has a garbage-collection mechanism which automatically clears out session stores. Every time session_start() is invoked, PHP randomly picks a number. If that number is equal to or smaller than session.gc_probability divided by session.gc_divisor, then PHP starts garbage-collection.
PHP decides what is garbage based on session.gc_maxlifetime. Any session stores older in seconds than that value will be deleted when the garbage-collection mechanism fires off. (Every time you run a script that manipulates sessions, the time/date stamp on that file is updated.)
So it may very well be that your browser is sending a session ID to PHP, but that PHP has already deleted the session store matching that ID. In which case your session variables will not be available.
Want the best answers?
Ask the best questions!
TANSTAAFL!!