0

I have a logout page on my site, which looks something like this:

<div id="fb-root"></div>
    <script>
      // Load the Facebook SDK Asynchronously
      (function(d){
         var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
         if (d.getElementById(id)) {return;}
         js = d.createElement('script'); js.id = id; js.async = true;
         js.src = "//connect.facebook.net/en_US/all.js";
         ref.parentNode.insertBefore(js, ref);
       }(document));

      // Init the SDK upon load
      window.fbAsyncInit = function() {
        FB.init({
          appId      : '[valid_app_id]' // App ID
        });
        FB.getLoginStatus(function(loginResponse){
          // As soon as we get the login status... log out!
            FB.logout(function(logoutResponse) {
            // logged out!
          }); 
        });
      } 
    </script>

The page functions perfectly well when accessed from a vanilla Chrome browser. However, if the

[x]Block third-party cookies and site data

option is checked under "Content settings..." for chrome, the page fails to logout users, and reports

FB.logout() called without an access token.

Is there a workaround to this problem? I'd like to be able to log users out, even when they have stricter-than-usual security settings.

blueberryfields
  • 45,910
  • 28
  • 89
  • 168

1 Answers1

0

I founded a solution that solved this problem, just define a empty value to your access token, and finaly redirect him to logout page using getLogoutUrl() mrthod:

$_SESSION['fb_YOUR_APP_ID_access_token'] = '';
$logout = $facebook->getLogoutUrl(array( 'next' => 'YOUR_LOGOUT_MESSAGE_PAGE'));
header("Location: $logout " );

Sorry for my bad english!