php session time left

If I set a session is there a way to determine the time the session will expire?
LVL 7
Robert SaylorSenior DeveloperAsked:
Who is Participating?
 
Dave BaldwinFixer of ProblemsCommented:
0
 
Dave BaldwinFixer of ProblemsCommented:
No.  The session expiration time is the minimum time before the session data is erased.  There is no actual 'timer'.  Session expiration is checked only when a PHP page is run and is only erased 1 in 100 times even then.  I have session data on one of my computers that is ten years old because I rarely use PHP on it.

The purpose of Sessions in PHP is to identify user data.  It is not to time out user 'sessions' and fails miserably when someone tries to use it that way.
0
 
Robert SaylorSenior DeveloperAuthor Commented:
Thanks Dave. I kinda suspected that but will leave this open for others to comment. In a nice world I want to warn my logged in user before php kills the session.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
Dave BaldwinFixer of ProblemsCommented:
PHP will not kill the session until someone requests a PHP page at the very least because that is the only time the PHP interpreter runs.  If there are no requests, the session will not expire.  If there is a request from the user, the session timeout is reset and starts all over.  We had a very long and difficult question / discussion on this last month.
0
 
Robert SaylorSenior DeveloperAuthor Commented:
Thanks for posting Ray's article.
0
 
Dave BaldwinFixer of ProblemsCommented:
You're welcome, glad to help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.