title: PHP session unset or PHP session destroy
body: <p>When I'm trying logout with: <code>session_destroy();</code> then it worked. But the problem is, I have also a shopping cart with sessions. So <code>session_destroy();</code> isn't a option for me. When I'm using the <code>unset($_SESSION['username']);</code> function it seems working. But when I go back to my accountpage, I'm just back logged in. My logout script looks like this:</p>
  
  <pre><code>&lt;?php
  unset($_SESSION['username']);
  unset($_SESSION['id']);
  
  header('Location: index?page=home');
  ?&gt;
  </code></pre>
  
  <p>I checked with this piece of code of a user is logged in. (Can somebody tell me also or this is safe?)</p>
  
  <pre><code>&lt;?php if (!$_SESSION['username'] &amp;&amp; !$_SESSION['id']){ ?&gt;
  &lt;?php header ('Location: index?page=home'); ?&gt;
  &lt;?php } ?&gt;
  </code></pre>
  
  <p>This is the info that you need (I think). If you need more, please ask me.</p>
  
  <p>So, my question in the short version: How can I destroy my session without destroying my shopping cart session? </p>
  
  <p>Thanks guys.</p>