Jump to content

Why do my SESSIONS not time out ?


vincej

Recommended Posts

Hi - Customer Access to my site is controlled through a login process. The userid is held in a SESSION. Looking at PHP MyAdmin the 

session.gc_maxlifetime

is 1440. However, I can continue to use the site even though I have been away for more than 1440.  The only way of killing the session is by totally closing the browser.

 

 

I would like to tim elimit a session, but clearly I am not doing something correct.

 

 

Any Advice as to what I need to do ?

 

 

Many Many Thanks !

Link to comment
Share on other sites

The session.gc_maxlifetime isn't for timing out sessions, it's for cleaning up old session data files. You shouldn't depend on the underlying operation of the session garbage collection to do anything your application depends on. Session garbage collection RANDOMLY runs, so old session data files can randomly exist long after they are older than the session.gc_maxlifetime value. Also, the last referenced time of the session data file is updated upon the session start, so if your session data file is older than the session.gc_maxlifetime value, but the file hasn't been delete yet when you access a page the has a session_start, your session will continue.

 

If you want some action to occur after a specific period of inactivity, you need to store a timestamp or datetime value and test on each page request if that timestamp or datatime value is farther in the past than you want and perform the desired action in your code.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.