title: How to log out user from facebook application, but maintain login from facebook
body: <p>I have tried the PHP SDK (v.3.1.1), and the current Javascript SDK 
  as suggested here :  <a href="https://developers.facebook.com/docs/guides/web/" rel="noreferrer">https://developers.facebook.com/docs/guides/web/</a></p>
  
  <p>now when trying to log out I have tried both FB.logout() ( for js ) 
  and $facebook->getLogoutUrl() ;</p>
  
  <p>as the documentation for both clearly state, these methods 
  log the user out of the application as well as their facebook session.</p>
  
  <p>But I only need to log the user out of the facebook application ( the test site ).</p>
  
  <p>I have tried logging the user out of my test site, ignoring the facebook
  aspect. But in this case, when the user clicks the login button again,
  the login flow ( facebook authentication and redirect ) does not happen.</p>
  
  <p>I also tried : ( as suggested by previous unresolved questions)</p>
  
  <pre><code>$facebook-&gt;destroySession();
  
  unset($_SESSION['fb_' . sfConfig::get('app_fb_config_id') . '_code']);
  unset($_SESSION['fb_' . sfConfig::get('app_fb_config_id') . '_access_token']);
  unset($_SESSION['fb_' . sfConfig::get('app_fb_config_id') . '_user_id']);    
  </code></pre>
  
  <p>however, when redirecting to the login page, $facebook->getUser() still
  retrieves the user.</p>
  
  <p>note :
  as per documentation example, I am using php sdk to login the user to my test site,
  and the js sdk, to render and facilitate the facebook login button. </p>
  
  <p>additional :</p>
  
  <p>the authentication i use is basically what documentation suggests : </p>
  
  <pre><code>&lt;?php
  
  define('YOUR_APP_ID', 'YOUR APP ID');
  
  //uses the PHP SDK.  Download from https://github.com/facebook/php-sdk
  require 'facebook.php';
  
  $facebook = new Facebook(array(
    'appId'  =&gt; YOUR_APP_ID,
    'secret' =&gt; 'YOUR APP SECRET',
  ));
  
  $userId = $facebook-&gt;getUser();
  
  ?&gt;
  
  &lt;html&gt;
    &lt;body&gt;
      &lt;?php if ($userId) { 
        $userInfo = $facebook-&gt;api('/' + $userId); ?&gt;
        Welcome &lt;?= $userInfo['name'] ?&gt;
      &lt;?php } else { ?&gt;
      &lt;div id="fb-root"&gt;&lt;/div&gt;
      &lt;fb:login-button&gt;&lt;/fb:login-button&gt;
      &lt;?php } ?&gt;
      &lt;script&gt;
        window.fbAsyncInit = function() {
          FB.init({
            appId      : '&lt;?= YOUR_APP_ID ?&gt;',
            status     : true, 
            cookie     : true,
            xfbml      : true,
            oauth      : true,
          });
  
          FB.Event.subscribe('auth.login', function(response) {
            window.location.reload();
          });
        };
  
        (function(d){
           var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
           js = d.createElement('script'); js.id = id; js.async = true;
           js.src = "//connect.facebook.net/en_US/all.js";
           d.getElementsByTagName('head')[0].appendChild(js);
         }(document));
      &lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>