Jump to content

Session Lifetime


JustinK101

Recommended Posts

What is the lifetime of a standard php session created by simply session_start(); and $_SESSION = "test123"? From my understanding sessions live until the user closes their browser.

 

Assuming the user doesn't close their browser but leaves their computer completely idle for say 12 hours will the session still persist? What about the server clearing temp automatically?

 

Basically I need sessions to always exist until the user closes their browser or a minimum of 8 hours.

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/108952-session-lifetime/
Share on other sites

The best way would be to set these in your php.ini file directly if you have access to it. However this will then be system wide and any other sites on the server will have the same session length, hopefully you see the security risk of having such long session times.

 

Otherwise use the code above as the first two lines of your PHP script, before anything else.

Link to comment
https://forums.phpfreaks.com/topic/108952-session-lifetime/#findComment-558961
Share on other sites

If you are on a shared host and your session.save_path setting is the default shared folder, the shortest session.gc_maxlifetime of all the scripts running on the host will win and remove any of your session data files (ending those sessions) that are older than the session.gc_maxlifetime value in effect for a session_start() that triggers garbage collection.

 

In this case, you would also need to also set the session.save_path to be a folder within your hosting account's directory structure.

Link to comment
https://forums.phpfreaks.com/topic/108952-session-lifetime/#findComment-559215
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.