已从Facebook注销,但仍重新注册$user

Logged out of Facebook but it still reconginizes $user

本文关键字:注册 user 新注册 注销 Facebook 已从      更新时间:2023-09-26

全部,我正在使用Facebook Connect(JS SDK)对我的网站的用户进行身份验证。我正在检查我的网站上是否设置了登录会话变量,然后再点击代码检查用户是否登录了facebook。然而,这一切都很好,当用户从facebook注销并从我的网站注销时,我试图重新登录,它仍然认为用户登录了facebook,尽管我知道他们没有。我该如何防止这种情况发生?我试图在登录按钮上设置autologoutlink=true,但似乎不起作用。

有什么想法吗?

谢谢!

@Madan提供的解决方案对我很有效。由于我的应用程序是基于ajax的,因此我无法重新加载浏览器。我每分钟运行一个setInterval()回调函数来检查用户是否仍在登录facebook。

setInterval(function (){
    FB.getLoginStatus(function(response){
        if(response.status ==='unknown' && FB_LOGIN==1){
            alert('Your Facebook session has been expired');
            member_logout();
        }
    }, true);
},60000);

它就像一个符咒。

始终将FB.getLoginStatus中的第二个参数(callback,true)设为true。。。这是因为facebook的响应缓存在SDK中。因此,使用always true参数检查当前用户会话。

在调用FB.getLoginStats()并根据这些结果将用户重定向到适当的内容时,我总是取得了很好的结果。三个条件(尽管对于一个应用程序,在我看来,后两个条件完全相同)

https://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus/

FB.getLoginStatus(function(response) {
  if (response.status === 'connected') {
    // the user is logged in and connected to your
    // app, and response.authResponse supplies
    // the user's ID, a valid access token, a signed
    // request, and the time the access token 
    // and signed request each expire
    var uid = response.authResponse.userID;
    var accessToken = response.authResponse.accessToken;
  } else if (response.status === 'not_authorized') {
    // the user is logged in to Facebook, 
    //but not connected to the app
  } else {
    // the user isn't even logged in to Facebook.
  }
 });
$facebook->destroySession();

或者你可以去这个链接

Facebook getUser()函数在退出后返回用户ID