问题描述
背景:
- 使用Facebook PHP SDK v 2.1.2
- cookieSupport = true
- Facebook上的应用程式已启用Canvas的OAuth 2.0
- Facebook连线/登入逻辑是透过单独的子网域(secure.mysite.com)
- 开发网站为dev.mysite.com:PORT_NUM
- 我可以使用Facebook Connect成功登录
- 在通过Facebook对话框授权后,重定向到fbconnect.php,它实例化Facebook类并调用$ facebook-> getSession()
- 这返回一个有效的Facebook会话,然后继续我们的post-signin逻辑
- 然后我们重定向到已登录的主页 。
不起作用
- 之后的任何时间,$ facebook-> getSession()返回NULL。无论是什么。
- 根据文档,Facebook应根据cookie重新生成有效的会话,只要它有效。持续时间设置为默认值1小时,但是在Cookie设置失败后30秒内完成调用。
想知道fbs_ cookie中是否有某些东西阻止了登录后会话的再生。与安全子域相关的东西或者我们在开发者网站上使用的端口号?
有很多人在Facebook会话中遇到类似的问题看到,但是我遇到的建议似乎没有解决fbs_ cookie,域,端口等的内容。我理解这样的事情与cookie的关系相对较轻,但我想至少检查他们作为非问题,所以我可以看别处。
欣赏任何分析。
新的Facebook PHP SDK(v3)问题消失了
Background:
- Using Facebook PHP SDK v 2.1.2
- cookieSupport = true
- App on Facebook has OAuth 2.0 for Canvas enabled
- Facebook Connect / sign in logic happens over https on a separate subdomain (secure.mysite.com)
- Dev sites are dev.mysite.com:PORT_NUM
What works
- I can sign in successfully using Facebook Connect
- After authorizing via Facebook dialog, we sign the user in and then redirect to fbconnect.php which instantiates the Facebook class and calls $facebook->getSession()
- This returns a valid Facebook session and we proceed with our post-signIn logic
- We then redirect to the signed in home page
What doesn't work
- Any time after that, the $facebook->getSession() returns NULL. No matter what.
- According to the docs, Facebook should regenerate a valid session based on the cookie as long as it's valid. The duration is set to the default of 1 hour, but calls done even 30 seconds after the cookie is set fail.
I'm wondering if there's something in the fbs_ cookie that's preventing the regeneration of a session post sign-in. Something related to the secure subdomain or possibly the port numbers we use on our dev sites?
There are a lot of people having similar problems with Facebook sessions from what I've seen, but the suggestions I've come across don't seem to address the content of the fbs_ cookie, domains, ports etc. My understanding of how such things relate to cookies is relatively light, but I'd like to at least check them off as non-issues so I can look elsewhere.
Appreciate any insights.
This issue went away with the new Facebook PHP SDK (v3)
这篇关于Facebook PHP SDK getSession()无法获取会话。 Cookie问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!