Facebook Logout – How to log the person out of Facebook

Question:

The Login part is OK. I had to add a "Aren't you x? Click here to login with another account" which calls the following function:

function deslogarFacebook(){

    FB.logout(function (response){

    window.location.href = "login";

}); }

It is sending back to the login screen. However, it still keeps showing "Continue as X" (where X is the name of the person who is logged in to Facebook) and I would like by clicking this button to log the person out of Facebook too so they can log in with another account.

I've read the Facebook Developers documentation but it only says that there are 3 cases regarding FB.Logout but it doesn't explain how I can actually log out the person from Facebook so that they can log in with another account.

Answer:

I found the solution and it was as follows. Added this code to window.fbAsyncInit:

FB.Event.subscribe("auth.logout", function(){       
    window.location = '[sua tela de login aqui]'
});

And the logout button from Facebook when the person wants to log in with another account:

<div class="fb-login-button" data-max-rows="1" data-size="large" data-button-type="continue_with" data-show-faces="false" data-auto-logout-link="true" data-use-continue-as="false"></div>
Scroll to Top