Posted By

kidmizere on 03/26/14


Tagged

session timeout


Versions (?)

Session Timeout


 / Published in: PHP
 

URL: http://www.daniweb.com/web-development/php/threads/124500/session-time-out-in-php

This is a neat little process for setting a timer and ending a session - change time to reflect minutes for timeout, change redirect to your logout page

  1. // set timeout period in seconds (600 = 10 minutes)
  2. $inactive = 600;
  3. // check to see if $_SESSION['timeout'] is set
  4. if(isset($_SESSION['timeout']) ) {
  5. $session_life = time() - $_SESSION['timeout'];
  6. if($session_life > $inactive)
  7. { session_destroy(); header("Location: logoutpage.php"); }
  8. }
  9. $_SESSION['timeout'] = time()

Report this snippet  

You need to login to post a comment.