0

I have an application with php laravel where it is used to authenticate Socialite / Facebook and I would like it when I close the session, it closes both for my application and for Facebook.

We are already trying to redirect to

https://www.facebook.com/logout.php?next=urlapp/&access_token=tokenauth

and it does not work.

How can I close the Facebook session?

miguelug
  • 547
  • 4
  • 10

1 Answers1

0

I solved it with the Facebook SDK javascript adding:

(function (d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) {
            return;
        }
        js = d.createElement(s);
        js.id = id;
        js.src = "https://connect.facebook.net/en_US/sdk.js";
        fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));

window.fbAsyncInit = function () {
        FB.init({
            appId: 'myAppID',
            status: true,
            cookie: true,
            oauth: true,
            xfbml: true,
            version: 'v2.7'
        });
    }

Then in the action of my logout button:

FB.getLoginStatus(function(response) {
            if ((response.status)&&(response.status=='connected')) {
                FB.logout(function(response) {
                    //manage: user is logout
                    console.log(response);
                });
            } else {
               //manage: user is not connected.
            }
        });

The 3 disconnection scenarios mentioned in the documentation are important: https://developers.facebook.com/docs/reference/javascript/FB.logout/

miguelug
  • 547
  • 4
  • 10