Jump to content

Very Quick, simple, session expiry question.


johnsmith153

Recommended Posts

session.cookie_lifetime is currently set to 0 (I believe that means it stays active until the browser is closed)

 

session.gc_maxlifetime is currently set to 1440 (24 minutes. Something about garbage collector lifetime.)

 

(I can change php.ini etc no problem or even set in script.)

 

My questions.

 

1. Will my session last until browser closes, or will it only last 24 minutes (I.e is it overidden by the max life time.) - are these two related?

(I want a 40 minute session.)

2. Should I use the above commands and change or should I just leave and use something like:

 

$expiretime = 60*40;

$_SESSION['expire'] = time()+$expiretime; // Set when you login

if ($_SESSION['expire'] > time()) // Checks if session is still valid on every page

Link to comment
Share on other sites

gc_maxlifetime is like an idle timeout - if the user doesn't hit a page with the session active for 24 minutes, then the session will disappear.  It sounds like you should increase this to 40 minutes to get the behaviour you want.

 

The relationship between the two settings is that if either runs out, the session is destroyed.  So it's an "or" relationship.

Link to comment
Share on other sites

And if you are on a shared hosting server using the default session.save_path, the shortest session.gc_maxlifetime being set by any of the scripts will win and delete your session data files when GC runs. So, you need to change the session.save_path to be a folder within your account space.

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.