title: Destroy all session variables with PHP
body: <p>I am trying to get rid of a bunch of session variables in PHP. I mean completely get rid of them.</p>
  
  <p>I have tried some different approaches. For example:</p>
  
  <pre><code>$_SESSION = array();
  session_destroy();
  header('location: '.MAINPATH);
  </code></pre>
  
  <p>I have also tried using various compinations of session_unset, unset, setcookie etc. with the above commands.
  I have of course tested if the session variables remains by doing:</p>
  
  <pre><code>echo $_SESSION['member_id'];
  </code></pre>
  
  <p>All of my session variables still remains for som reason.
  Can anyone figure out what the problem might be?</p>
  
  <p>Any help is greatly appreciated.</p>
  
  <p>FWI: I am using PHP 5.5</p>
  
  <p>UPDATE:
  I tried changing my code to the following:</p>
  
  <pre><code>echo $_SESSION['member_id'];
  session_unset();
  session_destroy();
  echo $_SESSION['member_id'];
  </code></pre>
  
  <p>which resulted in this output:</p>
  
  <blockquote>
    <p>1000004 Notice: Undefined index: member_id in...</p>
  </blockquote>
  
  <p>This should mean that the session variable is deletede right? The weird thing is, that when I am going back to my front page, the session variable is available again.</p>