Search code examples
facebookfacebook-likefacebook-social-plugins

FB.getLoginStatus inside edge.create callback is returning unknown status and null session after logging in from the popup


Has anybody tested the scenario below?

1- Log out of Facebook

2- Go to page that has the like button

3- Click like then log in to Facebook from the popup window

I am subscribed to edge.create and calling FB.getLoginStatus(function(response) { }); in order to make sure the user is logged in when the like button is clicked.

When the like button is clicked, response status is unknown and session is null which is not what I'm expecting there.

    FB.Event.subscribe('edge.create', function(href) {
        FB.getLoginStatus(function(response) {
            alert("inside edge create login status callback" + JSON.stringify(response));
        });
    });

Solution

  • Found the solution: Calling FB.getLoginStatus with the second param "true" forces it to get the login status from the server.

    FB.getLoginStatus(function(response) {}, true)