Darkness Soul Posted October 18, 2006 Share Posted October 18, 2006 yo, :DGuys, 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.. :-[Thank you,D.Soul Quote Link to comment Share on other sites More sharing options...
trq Posted October 18, 2006 Share Posted October 18, 2006 [url=http://php.net/ini_set]ini_set[/url] should help you out. Quote Link to comment Share on other sites More sharing options...
Darkness Soul Posted October 18, 2006 Author Share Posted October 18, 2006 so, is that correct?[code]// before start, in all filesini_set ( "session.gc_maxlifetime" , "2400" ) ;session_start () ;[/code]or should I use "session.cache_expire" ? Quote Link to comment Share on other sites More sharing options...
Destruction Posted October 18, 2006 Share Posted October 18, 2006 [quote]session.gc_maxlifetime integersession.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 Quote Link to comment Share on other sites More sharing options...
Darkness Soul Posted October 18, 2006 Author Share Posted October 18, 2006 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 Quote Link to comment Share on other sites More sharing options...
Destruction Posted October 18, 2006 Share Posted October 18, 2006 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 Quote Link to comment Share on other sites More sharing options...
Darkness Soul Posted October 19, 2006 Author Share Posted October 19, 2006 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.