title: How to destroy Session automatically after 5 minutes of inactivity on website in php
body: <p>I am using this block of code for mannual logout but i want automatic logout after 5 minutes of inactivity on website. How to do that? 
  Thanks </p>
  
  <pre><code>&lt;?php
  session_start();
  error_reporting(E_ALL);
  ini_set('display_errors', '1');
  session_destroy();
  
  if(!session_is_registered('username')) {
    header("location: logout_msg.html");
  } else {
    print "&lt;h2&gt;Could not log you out, sorry the system encountered an error.&lt;/h2&gt;";
  }
  
  exit();
  ?&gt; 
  </code></pre>