Session life time
Posted 18 October 2006 - 05:57 PM
Guys, I've been look for a function to extend my session life time, unhappy, I don't found.
By default, a session have 30 minutes as life time, but I need 40 minutes..
Posted 18 October 2006 - 06:18 PM
// before start, in all files ini_set ( "session.gc_maxlifetime" , "2400" ) ; session_start () ;
or should I use "session.cache_expire" ?
Posted 18 October 2006 - 07:17 PM
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.
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,
Posted 18 October 2006 - 07:28 PM
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?
Posted 18 October 2006 - 07:37 PM
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.
Posted 19 October 2006 - 12:31 PM
I've tested it, it's kill the session for some reason, but not like I wanna =(..
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() ;
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users