【发布时间】:2011-09-17 13:35:41
【问题描述】:
我发现了几个类似的问题,但都讨论了用户是否通过连接注销。我在问一个不同的问题:
我有一个应用程序,用户已经在 Facebook 登录并且已经添加了这个应用程序。因此,在应用程序主页上,它显示“欢迎用户名”,因为用户会话已经存在。
接下来,我从 FaceBook.com(不是我的应用程序)注销,打开 facebook.com,然后从右侧菜单中单击 Logged Out !并看到一条消息,我已注销。
我再次打开我的应用程序,进行了几次刷新,但仍然显示“欢迎用户名”。它应该说“登录 Facebook”而不是欢迎信息,因为我已经在 Facebook 上注销了。
以下是我用来获取 FB 会话的内容。
$session = $facebook->getSession();
if(!empty($session)) {
# Active session, let's try getting the user id (getUser()) and user info (api->('/me'))
try{
$uid = $facebook->getUser();
$user = $facebook->api('/me');
} catch (Exception $e){}
if(!empty($user)){
# User info ok? Let's print it (Here we will be adding the login and registering routines)
print_r($user);
} else {
# For testing purposes, if there was an error, let's kill the script
die("There was an error.");
}
}
请指导我如何解决这个问题。
【问题讨论】:
-
但是这样会过期所有的cookie,有没有办法针对特定的cookie来解决这个问题?