7

I want to up the time my users will stay logged into my site without getting automatically logged out after a period of inactivity. I'm tracking the logged in status using PHP sessions.

How can I set this, I'm trying to control this from my .htaccess file.

random
  • 9,774
  • 10
  • 66
  • 83
Ian
  • 11,920
  • 27
  • 61
  • 77
  • 1
    possible duplicate of [How do I expire a PHP session after 30 minutes?](http://stackoverflow.com/questions/520237/how-do-i-expire-a-php-session-after-30-minutes) – Álvaro González Jan 30 '12 at 09:53
  • 1
    For anyone finding this in 2012 or beyond. There is a wealth of here http://stackoverflow.com/questions/520237/how-do-i-expire-a-php-session-after-30-minutes that you might want to read first! (read the top answer) – KB. Mar 28 '12 at 09:00

2 Answers2

17

You can't do that from the htaccess file but You can change this line in your php.ini file.

session.gc_maxlifetime = 1440

Update: it seems to be possible, so i stand corrected

php_value session.gc_maxlifetime 3600

I haven't tried this out though.

Starx
  • 77,474
  • 47
  • 185
  • 261
Ólafur Waage
  • 68,817
  • 22
  • 142
  • 198
7

You could also try changing the value at runtime using ini_set:

ini_set('session.gc_maxlifetime', '3600');
random
  • 9,774
  • 10
  • 66
  • 83
Asciant
  • 2,130
  • 1
  • 15
  • 26