how to destroy the session if the application is exceeding more than its given idel time using php
<p>in my program for a security purpose it is neccessary to  destroy the session variable if the application exceed more than its idle time.For This i am using this code,</p>

<blockquote>
  <p>// set timeout period in seconds
  $inactive = 300;</p>
  
  <p>// check to see if
  $_SESSION['timeout'] is set
  if(isset($_SESSION['timeout']) ) {
    $session_life = time() -
  $_SESSION['start'];   if($session_life</p>
  
  <blockquote>
    <p>$inactive)
            { session_destroy(); header("Location: logout.php"); } }
    $_SESSION['timeout'] = time();</p>
  </blockquote>
</blockquote>

<p>But this code refresh the session variable every  5 min, i want to know how to destroy the session variable if the system is in the idle time. And also please tell me it create any other problem if i destroy the session variable . Thanks in advance</p>
