dougou8573 2011-07-14 08:19
浏览 71
已采纳

与GET的PHP会话有IE8和Facebook应用程序的问题

I am developing a facebook app. I was using Sessions with cookies and it was all working fine. Suddenly IE8 has some errors with cookies. It was blocking my site because it was in iframe. So I came to know about P3P Header. I used that correctly and problem solved. But client now want me to use GET if cookies are not available. I am doing it but now I am facing problem that facebook PHP Sdk has problem in its session. Its getSession method is not getting session and redirecting to authenticate the user and then redirect back to the app. but in all this it loses the GET variable PHPSESSID. Following is a thread of stackoverflow that has some thing similar so may be for you guys following is helpful. Facebook PHP SDK getSession() fails to get session. Cookie problem?

This is the code used to have Sessions with GET if Cookies are not available:

ini_set( 'session.use_cookies_only', false );
ini_set( 'session.use_trans_sid', true );

session_start();

This is the code for accessing fb. session with 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();

Please tell if you can give me any clue.

thanks to all of you

  • 写回答

1条回答 默认 最新

  • dongshanxiao7328 2011-07-14 10:15
    关注

    This seems to be a never ending issue with facebook API. There session functionality breaks randomly and you can do much about it. What I usually do in my applications is to disable cookies and store facebook session in my own application SESSION. There is a parent controller which is called on each request which is responsable for checking SESSION. If a valid SESSION is found, it is set to facebook's session object. This ensures that a valid session will be returned on calling getSession().

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥200 关于#c++#的问题,请各位专家解答!网站的邀请码
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号