Jump to content

Session life time


Darkness Soul

Recommended Posts

[quote]
session.gc_maxlifetime integer

session.gc_maxlifetime specifies the number of seconds after which data will be seen as 'garbage' and cleaned up. Garbage collection occurs during session start.

Note: If different scripts have different values of session.gc_maxlifetime but share the same place for storing the session data then the script with the minimum value will be cleaning the data. In this case, use this directive together with session.save_path.
[/quote]

The manual has all the answers ;)

In other words, yes the maximum time for session data to remain in storage is set by session.gc_maxlifetime.  However, when the browser is closed or cookies cleared, the session may expire clientside.  To keep the session persistent regardless of this you will need to set the sessionid into a cookie and as long as the client maintains that cookie, the session will be kept - up to the maximum lifetime (which is updated everytime the session is used). 

Hope this helps,

Dest
Link to comment
Share on other sites

Thank you Dest, but still "broke"..

I've write this code at main.php page with the time set to 5 seconds, so I've tried to wait and reload. It was with the session data yet.. =(

My login system use a session variable to hold the auth permission, so, the main redirect to the index when it "burn away"..

:'( I'm without options.. another way?

D.Soul
Link to comment
Share on other sites

GC = Garbage Collection and isn't run every time.  It's set by the divisor etc.

You could set it manually within your code like a tracking system.  I believe there's a tutorial on phpfreaks that shows how to track users online time.  You could make it so that if they went over that time period, it changed the session value for auth.

Dest
Link to comment
Share on other sites

Yo,

I've tested it, it's kill the session for some reason, but not like I wanna =(..

[code]ini_set ( 'session.use_cookies' , true ) ;
ini_set ( 'session.name' , 'the_sess__uniq_name' ) ;
ini_set ( 'session.auto_start' , false ) ;
ini_set ( 'session.gc_maxlifetime' , 5 ) ;  // in seconds, like: N + time()
ini_set ( 'session.cookie_lifetime' , 5 ) ;  // in seconds, like: N + time()
ini_set ( 'session.serialize_handler' , 'php' ) ;
ini_set ( 'session.gc_probability' , 1 ) ;
session_start() ;[/code]

D.Soul
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.