Facebook getUser()函数退出后返回用户ID [英] Facebook getUser() function returning user ID after logout

查看:75
本文介绍了Facebook getUser()函数退出后返回用户ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发使用Facebook PHP SDK。

I'm developing using the Facebook PHP SDK.

我想让它成为当用户退出Facebook时,他们将自动注销我的网站也是。

I wanted to make it so that when the user logs out of Facebook, they will automatically be logged out of my website too.

我使用以下代码检测会话,使用会话cookie:

I am using the following code to detect the session, using the session cookie:

$facebook->getUser();

由于某种原因, getUser()即使在他们的网站上注销了Facebook后,功能仍会返回用户的Facebook ID。

For some reason, the getUser() function still returns the user's Facebook ID, even after they have logged out of Facebook on their website.

我是否先使用另一个功能检测会话?

Am I to detect the session first using another Function?

官方文档示例这里,是他们评论中的以下摘录:

On the official documentation example here, is the following excerpt from their comments:

// Get User ID
$user = $facebook->getUser();

// We may or may not have this data based on whether the user is logged in.
//
// If we have a $user id here, it means we know the user is logged into
// Facebook, but we don't know if the access token is valid. An access
// token is invalid if the user logged out of Facebook.

这导致我相信Facebook的会话cookie在Facebook注销时会变得不成功?

This lead me to believe that the session cookie for Facebook would become unset upon Facebook logout?

Kind Regards,

Kind Regards,

Luke

推荐答案

我有同样的问题!

FB PHP SDK将这些东西保存到$ _SESSION!
当您的用户点击退出时,您可以这样删除它们:

The FB PHP SDK saves those things into the $_SESSION! You can delete them like this when your user clicks logout:

$_SESSION['fb_'.APP_ID.'_user_id'] = '';
$_SESSION['fb_'.APP_ID.'_access_token'] = '';

虽然这不是最终的解决方案,但现在可以工作。

Although this is not the final solution, it works for now.

我感谢您的评论和解决方案!

I appreciate comments and solutions on that!

这篇关于Facebook getUser()函数退出后返回用户ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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