title: PHP session timeout script
body: <p>I have this code that logs a user out if they don't change pages for 10 minutes.</p>
  
  <pre><code>$inactive = 600;
  
  if(isset($_SESSION['timeout']) ) {
    $session_life = time() - $_SESSION['timeout'];
    if($session_life &gt; $inactive) { 
      header("Location: logout.php"); 
    }
  }
  
  $_SESSION['timeout'] = time();
  </code></pre>
  
  <p>As you can see it's pretty straightforward. I include this function at the top of all my protected pages and if the script isn't run for 10 minutes, the next time you refresh the page, the user is sent to my logout script. </p>
  
  <p>However that's the problem. After $session_life > $inactive becomes true, the script needs to be run again for the user to be logged out. I need the person to be immediately logged out as soon as this becomes true. </p>
  
  <p>Is there any way to do this without things getting too complicated? (i.e. not using AJAX)</p>