1

I am trying to get my $_SESSIONS to expire in 30 days. I do not deal with any sensitive data on my server, so I am not worried about cookie hi-jacking. Would this work?

ini_set('session.cookie_lifetime', 2592000); 
ini_set('session.gc_maxlifetime', 2592000);
session_start();

Thanks in advance.

three3
  • 2,756
  • 14
  • 57
  • 85
  • Take a look at; http://stackoverflow.com/questions/520237/how-do-i-expire-a-php-session-after-30-minutes – Blazer Jan 06 '12 at 20:53

1 Answers1

4

In addition to your cookie, there are some other settings you need to look at in your php.ini.

You can manipulate them in code as follows:

// Current Session Timeout Value
$currentTimeout= ini_get('session.gc_maxlifetime');

// Change session timeout value for a particular page load  - 1 month = ~2678400 seconds
ini_set('session.gc_maxlifetime', 2678400);

More here and here

Community
  • 1
  • 1
afuzzyllama
  • 6,538
  • 5
  • 47
  • 64