title: Session Auto logout Why?
body: <p>I added a session limit timeout to my page. And later on I remove it, but anytime I access the said page it still functions as though I haven't removed the session limit. That means the limit is still active but doesn't exit.</p>
  
  <ul>
  <li>PROBLEM</li>
  </ul>
  
  <p>Why, what have I not done?</p>
  
  <pre><code>$idle = xxx; 
  $session_life = time() - $_SESSION['timeout_logout'];
  if($session_life &gt; $idle)
  { 
      session_destroy(); header("Location: index.php"); 
  }
  S_SESSION['timeout_logout']=time();
  
  // without the session timeout code:
  
  &lt;?php
  //initialize the session
  if (!isset($_SESSION)) {
      session_start();
  }
  
  // ** Logout the current user. **
  $logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
  if ((isset($_SERVER['QUERY_STRING'])) &amp;&amp; ($_SERVER['QUERY_STRING'] != "")){
      $logoutAction .="&amp;". htmlentities($_SERVER['QUERY_STRING']);
      $msg = "You have been logout successfully.";
  }
  
  if ((isset($_GET['doLogout'])) &amp;&amp;($_GET['doLogout']=="true")){
      //to fully log out a visitor we need to clear the session varialbles
      $_SESSION['MM_Username'] = NULL;
      $_SESSION['MM_UserGroup'] = NULL;
      $_SESSION['PrevUrl'] = NULL;
      unset($_SESSION['MM_Username']);
      unset($_SESSION['MM_UserGroup']);
      unset($_SESSION['PrevUrl']);
  
      $logoutGoTo = "index.php";
      if ($logoutGoTo) {
          header("Location: $logoutGoTo");
          exit;
      }
  }
  ?&gt;
  </code></pre>