toledorodney

Session timeout for inactivity

Mar 26th, 2015
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.34 KB | None | 0 0
  1. if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 1800)) {
  2.     // last request was more than 30 minutes ago
  3.     session_unset();     // unset $_SESSION variable for the run-time
  4.     session_destroy();   // destroy session data in storage
  5. }
  6. $_SESSION['LAST_ACTIVITY'] = time(); // update last activity time stamp
Advertisement
Add Comment
Please, Sign In to add comment