PHP session timeout is 0, but the session is still expiring

I am running Apache 2.2 with the latest version of PHP and mysql.

In my PHP.ini file, I see that the session timeout is set to 0, that is, the session remains valid until the browser closes.

I noticed, however, that sometimes when you come in the morning and leave the browser open and log in overnight, the session seems to have expired.

Are there other configuration options that could expire the session? I just want to play around with the values ​​and see what time is best for my site.

Many thanks

Ed

+4
source share
1 answer

You can try:

http://in2.php.net/manual/en/session.configuration.php#ini.session.gc-maxlifetime

you can put this in your PHP file, the second parameter is the number of seconds after which the data will be considered garbage and potentially cleaned .:

ini_set('session.gc_maxlifetime', 30*60); 

Hope this help!

Edit:

Yes, I have to mention this, thanks for pointing out.

As suggested by Willem

"a call to this function must be completed before session_start (); - Willem"

Example:

 <?php ini_set('session.gc_maxlifetime', 30*60); session_start(); ?> 
+4
source

All Articles