Facebook PHP:用户退出Facebook后,无法使用其他用户登录我的应用程序 [英] Facebook PHP: After user logs out of facebook, they can't login to my app with another user

查看:231
本文介绍了Facebook PHP:用户退出Facebook后,无法使用其他用户登录我的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  1. 用户使用Facebook登录我的应用程序

  2. 用户退出Facebook ....有人来电脑...

  3. 第二个用户尝试访问我的应用程序(不同的Facebook帐户,相同计算机)

  4. 他们不能...而是脚本获取上一个用户的访问令牌。

我正在使用Facebook PHP SDK。



当用户第一次尝试登录时,我执行以下操作:

  unset($ _ REQUEST); 
unset($ _ COOKIE); //不知道两者是否必要
session_destroy();

然而,新的fb帐户仍然被认为是最后一个(我得到以前登录的用户访问令牌,当我尝试使用它时引发异常,因为该用户不再登录)。



我需要使用注销功能吗?我假设用户从Facebook上登录,这不是我想要做的,只是在我的应用程序中使用新用户开始新鲜。



任何想法?自从我清理一切以后,我真的很失去这个数据。希望它的东西愚蠢的我失踪了,但我以为我会问,如果有人知道什么。

解决方案

最终工作:

  $ fb_key ='fbsr _'。$ facebookConfig ['app_id']; 
setcookie($ fb_key,'',time() - 3600);
$ facebook-> destroySession();


Sorry for the confusing title, here's the situation...

  1. A user logs into my app with Facebook
  2. The user logs out of facebook....someone else comes to the computer...
  3. The second user tries to access my app (different facebook account, same computer)
  4. They can't...instead the script gets the access token for the previous user.

I'm using the facebook PHP SDK.

When the user tries to login for the first time I do the following;

unset($_REQUEST);
unset($_COOKIE); //don't know if both are necessary
session_destroy();

Yet SOMEHOW the new fb account is still recognized as the last one (I get the previously logged in users access token which throws an exception when I try to use it since that user isn't logged in anymore).

Do I need to use the logout function? I assume that logs the user out of facebook, which isn't want I want to do, just start fresh with a new user in my app.

Any ideas? I'm really at loss on where this data is persisting from since I'm clearing everything. Hopefully its something stupid I'm missing but I thought I'd ask in case anyone knew anything.

解决方案

This is what seemed to work in the end:

$fb_key = 'fbsr_'.$facebookConfig['app_id'];
setcookie($fb_key, '', time()-3600);
$facebook->destroySession();

这篇关于Facebook PHP:用户退出Facebook后,无法使用其他用户登录我的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆