我正在开发一个Facebook应用程序。我正在使用带有cookie的Sessions,一切正常。突然IE8在使用cookies时出现了一些错误。它阻止了我的网站,因为它在iframe中。所以我开始了解P3P Header。我正确地使用了它,问题解决了。但是如果没有cookie,客户现在希望我使用GET。我正在这样做,但现在我面临的问题是facebook PHP Sdk在其会话中有问题。它的getSession方法没有获取会话和重定向来验证用户,然后重定向回应用程序。但是在这一切中它失去了GET变量PHPSESSID。以下是stackoverflow的一个线程,它有一些类似的东西,所以可能对你们这些人有帮助。 Facebook PHP SDK getSession() fails to get session. Cookie problem?
如果Cookie不可用,这是用于使用GET进行会话的代码:
ini_set( 'session.use_cookies_only', false );
ini_set( 'session.use_trans_sid', true );
session_start();
这是访问fb的代码。与PHP Sdk会话。:
$facebook = new Facebook(array(
'appId' => FACEBOOK_APPID,
'secret' => FACEBOOK_SECRET,
'cookie' => true,
));
$this->facebook=$facebook;
// We may or may not have this data based on a $_GET or $_COOKIE based session.
// If we get a session here, it means we found a correctly signed session using
// the Application Secret only Facebook and the Application know. We dont know
// if it is still valid until we make an API call using the session. A session
// can become invalid if it has already expired (should not be getting the
// session back in this case) or if the user logged out of Facebook.
$this->session = $facebook->getSession();
请告诉我你是否可以给我任何线索。
感谢你们所有人
答案 0 :(得分:1)
这似乎是facebook API永无止境的问题。会话功能随机中断,你可以做很多事情。我在我的应用程序中通常做的是禁用cookie并在我自己的应用程序SESSION中存储facebook会话。每个请求都会调用一个父控制器,负责检查SESSION。如果找到有效的SESSION,则将其设置为facebook的会话对象。这可确保在调用getSession()时返回有效的会话。