-1

Possible Duplicate:
How do I expire a PHP session after 30 minutes?
How to set lifetime of session

How to increase or decrease the lifetime of a session? My requirement is session should timeout and all the session variables should be unset automatically after the prescribed time limit. I used this code but the session did not timeout.Why?

ini_set("session.gc_maxlifetime", 60);// should timeout after 1 minute
Community
  • 1
  • 1
Arun
  • 37
  • 6

1 Answers1

0

Try this:

if(isSet($_SESSION['started'])){
  if((mktime() - $_SESSION['started'] - 60*1) > 0){
    //logout, destroy session etc
  }
}else{
  $_SESSION['started'] = mktime();
}
Mas User
  • 166
  • 1
  • 5
  • 17