title: How to unset session without reloading page
body: <p>I want to log the user out without reloading the page, just updating some divs. This is what I have but obviously not working. The session unsets only after reloading the page.</p>
  
  <pre><code>$.ajax({
          url: "logout.php",
          method: "post",
          data: "account_type=twitter",
          success: function () {
  
          /*****do something***********/  
      }
  });
  </code></pre>
  
  <p>in logout.php</p>
  
  <pre><code>&lt;?php
      session_start();
  
      if(isset($_POST['account_type']) &amp;&amp; $_POST['account_type'] == "twitter") {
  
          unset($_SESSION['twitterId']);
          unset($_SESSION['twitterName']);
          unset($_SESSION['twitterPic']);
          unset($_SESSION['twitterUrl']);
          unset($_SESSION['access_token']);
          unset($_SESSION['token_oauth']);
  
          header("Location: index.php");
      }
  ?&gt;
  </code></pre>
  
  <p>some help would be greatly appreciated. Thanks!</p>