title: Facebook api php destroySession doesn't destroy javascript session/cookie
body: <p>What I'm trying to attempt is to log out of my website when hitting logout, but not log out of Facebook.  This is a stripped down version of my code, adapted from the example Facebook provide.</p>
  
  <p>What currently happens is that when logout is hit, the session is destroyed, the page reloads and then the event subscribes for auth.login and auth.logout fire on page load and send the page into a redirect loop.  </p>
  
  <p>I've tried having the logout section of code on a separate page and giving the user a link to click to return to the site, but again the auth.login fires on page load and logs the user back in.  </p>
  
  <p>What I am asking is how do I destroy the session in a way that won't log the user out of Facebook, but will not re-auth the user on my site automatically.  No matter what I try the auth.login fires automatically and re-auths the user!</p>
  
  <pre><code>&lt;?php
  
  
  require 'include/facebook/facebook.php';
  
  $facebook = new Facebook(array(
    'appId'  =&gt; 'API KEY',
     'secret' =&gt; 'API SECRET',
  ));
  
  if(isset($_POST['logout'])){
  $facebook-&gt;destroySession();
  
  
  
  if (isset($_SERVER['HTTP_COOKIE'])) {
          $cookies = explode(';', $_SERVER['HTTP_COOKIE']);
          foreach($cookies as $cookie) {
              $parts = explode('=', $cookie);
              $name = trim($parts[0]);
              setcookie($name, '', time()-3600);
              setcookie($name, '', time()-3600, '/');
              setcookie($name, '', time()-3600, '/','MY DOMAIN');
  
          }
      }
  
      $signed_request_cookie = 'fbsr_' . API KEY;
      setcookie($signed_request_cookie, "", time()-3600, '/', 'MY DOMAIN');
  
  
  }
  // See if there is a user from a cookie
   $user = $facebook-&gt;getUser();
  
  if ($user) {
    try {
      // Proceed knowing you have a logged in user who's authenticated.
      $user_profile = $facebook-&gt;api('/me');
    } catch (FacebookApiException $e) {
      echo '&lt;pre&gt;'.htmlspecialchars(print_r($e, true)).'&lt;/pre&gt;';
      $user = null;
    }
  }
  
  
  
  ?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html xmlns:fb="http://www.facebook.com/2008/fbml"&gt;
   &lt;body&gt;
     &lt;?php if ($user) { ?&gt;    
  
  
  Your user profile is
    &lt;pre&gt;
      &lt;?php print htmlspecialchars(print_r($user_profile, true)) ?&gt;
    &lt;/pre&gt;
  
    &lt;form action = "" method = "post"&gt;
  
    &lt;input type = "submit" name = "logout" value = "logout"/&gt; 
    &lt;/form&gt;
  &lt;?php } else { ?&gt;
    &lt;fb:login-button&gt;&lt;/fb:login-button&gt;
  &lt;?php } ?&gt;
  &lt;div id="fb-root"&gt;&lt;/div&gt;
  &lt;script&gt;
    window.fbAsyncInit = function() {
      FB.init({
        appId: '&lt;?php echo $facebook-&gt;getAppID() ?&gt;',
        channelUrl : '/channel.php', // Channel File
        cookie: true, 
        xfbml: true,
        oauth: true,
        status: true
      });
      FB.Event.subscribe('auth.login', function(response) {
  
        alert('logging');
        window.location.reload();
      });
      FB.Event.subscribe('auth.logout', function(response) {
  
        alert('logging out');
        window.location.reload();
      });
    };
    (function() {
      var e = document.createElement('script'); e.async = true;
      e.src = document.location.protocol +
        '//connect.facebook.net/en_US/all.js';
      document.getElementById('fb-root').appendChild(e);
    }());
  &lt;/script&gt;
  &lt;br /&gt;
  POST:
  &lt;?php 
  print_r($_POST);
  ?&gt;
  </code></pre>
  
  <p>
  </p>