Search code examples
phpsessionsession-variablessession-timeout

PHP session timeout


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?


Solution

  • 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