title: can I add a cookie logout to this script?
body: <p>I'm using this script to login users and I want to know if I can add a simple cookie that will automatically logout the user after 30 mins of inactivity.</p>
  
  <pre><code>...
  if($count){
          session_start();
         session_regenerate_id();
          $_SESSION['SESS_USERNAME'] = $myusername;
          $_SESSION['SESS_PASSWORD'] = $mypassword;
          session_write_close();
         header("location: login_success.php");
          }
  </code></pre>
  
  <p>which connects to:</p>
  
  <pre><code>&lt;?php
   session_start();
   if(!isset($_SESSION['SESS_USERNAME']) || !isset($_SESSION['SESS_PASSWORD']) ||     (trim($_SESSION['SESS_USERNAME']) == '')) {
              //someone's not logged in
      header("location: index.php"); //it's suppose to actually be there
              exit();
    }
   ?&gt;
  </code></pre>
  
  <p>then to end the session:</p>
  
  <pre><code>&lt;?php 
  session_start();
  session_destroy();
  ?&gt; 
  </code></pre>
  
  <p>is this possible? this script is off the net, as I don't know a lot about PHP just a bit, so if its difficult I won't bother!</p>
  
  <p>Thanks for your time!</p>