Facebook Javascript SDK: auth.sessionChange and auto.logout event only for page refresh

I have an implementation for my website to have a single facebook sign using their javascript sdk.

javascript adds cookies, and I deal with it.

The question is when a user logs out of Facebook, I would expect auth.sessionChange or auth.logout events to occur, but this only happens when the page is being refreshed.

Since my implementation is server-side, this means that after a user logs out of Facebook, they can access one secure page again before logging out correctly.

Is this commonplace, or are these events usually triggered right away and can I do something wrong in setting up the facebook app?

+3
source share
2 answers

Almost a year and a half later, I don’t know if this is useful, but I try these things myself and noticed that the subscription solution does not work if I enter Facebook from / to my site (and not from the current page containing the FB object, for example, using FB.login ()).

Also, by constantly polling getLoginStatus and getSession, nothing changes if I log in to / from facebook (! From my site).

My conclusion?! Their script is completely out of sync with real events on facebook. The only way that worked for me was to constantly do FB.ini (...). (It looks like a constant update)

I hope this will be useful for other ppl having the same problem ...?!?

0
source

auth.sessionChange auth.logout , ( FB):

<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
  FB.init({appId: 'your app id', status: true, cookie: true, xfbml: true});
  FB.Event.subscribe('auth.sessionChange', function(response) {
    if (response.session) {
      // A user has logged in, and a new cookie has been saved
    } else {
      // The user has logged out, and the cookie has been cleared
    }
  });
</script>

, , FB js sdk, 2 , (, jquery.bind())

0

Source: https://habr.com/ru/post/1757322/


All Articles