title: Redirecting script to index page
body: <p>I don't really know what is going wrong. I have my logout page which I redirected to the login folder:</p>
  
  <pre><code>&lt;?php
  
  //include $_SERVER['DOCUMENT_ROOT'].'/connect.php';
  include $_SERVER['DOCUMENT_ROOT'].'/functions.php';
  
  if(session_destroy()){
      if(isset($_COOKIE['user_name'])){
  setcookie("user_name", $user_name, time()-2592000); 
      }
  }
      header('location:'.$_SERVER['DOCUMENT_ROOT'].'/login/');
  ?&gt;
  </code></pre>
  
  <p>But it always redirects me back to my index page even when I try to run the code like this:</p>
  
  <pre><code>&lt;?php
  
  //include $_SERVER['DOCUMENT_ROOT'].'/connect.php';
  //include $_SERVER['DOCUMENT_ROOT'].'/functions.php';
  
  session_start();
  
  if(session_destroy()){
      if(isset($_COOKIE['user_name'])){
  setcookie("user_name", $user_name, time()-2592000); 
      }
  }
  ?&gt;
  </code></pre>
  
  <p>Without including any external page and no header location it still redirects me back to the index page and secondly it doesn't destroy the session after redirecting to the index page until I reload it. Please do any one know the possible cause?</p>