PHP session timeout
20,073
Solution 1
Ok - I've found the way and it works - in the .htaccess I simply added the following to increase the timeout to 5 hours:
php_value session.cookie_lifetime 18000
php_value session.gc_maxlifetime 18000
Solution 2
On many shared hosts all sessions are stored in the same location. Because of the way garbage collection works, this means everyone's sessions get deleted after the shortest GC interval.
One solution is to do:
php_value session.save_path "/my/personal/path"
php_value session.gc_maxlifetime "3600"
Alternatively you can set a custom session save handler. Try changing your save path first, because custom handlers are a bit trickier.
Author by
user398341
Updated on July 14, 2022Comments
-
user398341 almost 2 years
Can someone explain exactly how to make the session to last for longer in PHP, but without using php.ini?
I've tried the following in .htaccess:
<IfModule mod_php5.c> #Session timeout php_value session.cookie_lifetime 3600 php_value session.gc_maxlifetime 3600 </IfModule>
I've also tried:
ini_set('session.gc_maxlifetime', '3600');
But none of them seem to be working.
Any idea?