Jump to content


Photo

Session life time


  • Please log in to reply
6 replies to this topic

#1 Darkness Soul

Darkness Soul
  • Members
  • PipPipPip
  • Advanced Member
  • 133 posts
  • LocationBrazil; São Paulo.

Posted 18 October 2006 - 05:57 PM

yo, :D

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.. :-[

Thank you,

D.Soul
(If something is wrong, please tell me. I'm learning this language. Thank you)

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 18 October 2006 - 06:01 PM

ini_set should help you out.

#3 Darkness Soul

Darkness Soul
  • Members
  • PipPipPip
  • Advanced Member
  • 133 posts
  • LocationBrazil; São Paulo.

Posted 18 October 2006 - 06:18 PM

so, is that correct?

// before start, in all files
ini_set ( "session.gc_maxlifetime" , "2400" ) ;
session_start () ;

or should I use "session.cache_expire" ?
(If something is wrong, please tell me. I'm learning this language. Thank you)

#4 Destruction

Destruction
  • Members
  • PipPipPip
  • Advanced Member
  • 108 posts

Posted 18 October 2006 - 07:17 PM

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.


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

#5 Darkness Soul

Darkness Soul
  • Members
  • PipPipPip
  • Advanced Member
  • 133 posts
  • LocationBrazil; São Paulo.

Posted 18 October 2006 - 07:28 PM

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
(If something is wrong, please tell me. I'm learning this language. Thank you)

#6 Destruction

Destruction
  • Members
  • PipPipPip
  • Advanced Member
  • 108 posts

Posted 18 October 2006 - 07:37 PM

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

#7 Darkness Soul

Darkness Soul
  • Members
  • PipPipPip
  • Advanced Member
  • 133 posts
  • LocationBrazil; São Paulo.

Posted 19 October 2006 - 12:31 PM

Yo,

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() ;

D.Soul

(If something is wrong, please tell me. I'm learning this language. Thank you)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users