Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook JS SDK FB.logout() doesn't terminate user session

I'm attempting to log a user out of facebook with the Facebook JS SDK, however calling:

FB.logout(function(response){
    console.log(response);
});

returns: response.status == "connected"

And only after refreshing the page does the SDK realize that the session has ended. Anyone know what could be causing this behavior? This code previously worked in my application and has recently started behaving this way.

Another example using FireBug:

enter image description here

like image 206
Casey Flynn Avatar asked Jan 11 '12 10:01

Casey Flynn


2 Answers

https://developers.facebook.com/bugs/245362365535898?browse=search_4f112135664703a96454690 This is a bug in the JS SDK that has now been fixed and it should get pushed in not too long.
Until then you can do the following

FB.logout(function(response) {
  FB.Auth.setAuthResponse(null, 'unknown');
  ...
});
like image 59
Sean Kinsey Avatar answered Nov 12 '22 19:11

Sean Kinsey


See http://hustoknow.blogspot.com/2012/01/dealing-with-zombie-facebook-cookies.html

When you logout, a cross-domain request gets sent to Facebook to invalidate the session. When you hit reload, another request gets sent to Facebook's site -- since FB recognizes the cookie as invalid, it correctly deletes the cookie from your browser.

I suspect it's a regexp bug in how they forgot to parse the fbm_ cookie, recently introduced in the last day or so. I'm just surprised that this fix hasn't been pushed.

like image 3
Roger Avatar answered Nov 12 '22 21:11

Roger