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,571
  • 10
  • 67
  • 79
Ian
  • 11,380
  • 26
  • 60
  • 76
  • 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
  • 75,098
  • 44
  • 181
  • 258
Ólafur Waage
  • 66,813
  • 19
  • 139
  • 194
7

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

ini_set('session.gc_maxlifetime', '3600');
random
  • 9,571
  • 10
  • 67
  • 79
Asciant
  • 2,120
  • 1
  • 15
  • 24