Safari 会话变量中具有多个页面的 Facebook Iframe 应用程序不持久 [英] Facebook Iframe App with multiple pages in Safari Session Variables not persisting

查看:15
本文介绍了Safari 会话变量中具有多个页面的 Facebook Iframe 应用程序不持久的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含多个 PHP 页面的 Facebook Iframe 应用程序.

I have a facebook Iframe application with multiple PHP pages in it.

我有一些链接指向我的iframe 文件夹"中的文件.

I have some links that point relatively to the files inside my "iframe folder".

iframe 中的会话变量存在一些问题.我设置了一些会话变量,但它们不会从一个页面持续到另一个页面.

Having some issues with session variables inside the iframe. I set some session variables but they do not persist from one page to another.

这确实适用于其他浏览器.

This does work on other browsers.

我一直在读到 Safari 不支持跨域 cookie,这可能是问题所在,但我不知道如何解决这个问题.

I've been reading that Safari does not support Cross-Domain cookies and this might be the problem , but im not sure how to fix this.

有什么帮助吗?

推荐答案

我写了 博文多米尼克在他的回答中提到.

I wrote the blog post Dominic refers to in his answer.

问题在于 Safari 的默认行为是仅接受来自您访问的站点的 cookie.这不包括第三方"cookie.Safari 将 IFRAME 内的页面视为第三方站点,并且在您与该内容交互(例如,通过单击链接)之前,它会拒绝这些 cookie.

The problem is that the default behavior of Safari is to only accept cookies from sites that you visit. This excludes "third party" cookies. Safari treats the page inside an IFRAME as a third-party site, and until you interact with that content (by clicking a link, for example), it will refuse those cookies.

您的 PHP 代码需要在使用会话的第一个页面上设置一个 cookie,以便该会话从一个页面持续到另一个页面,但是如果会话变量位于 IFRAME 的第一个页面中,则您有一个鸡和蛋的问题.

Your PHP code needs to set a cookie on the first page that uses the session in order for that session to persist from one page to another, but if the session variables are in the very first page in the IFRAME, you have a chicken-and-egg problem.

我的解决方案是保留所有特殊的 Facebook 参数,直到加载到 IFRAME 的第二个页面.因为您已经与它进行了交互,所以在第二个页面上设置的 cookie 将持续存在,这允许您的 PHP 代码保持与 Facebook 通信所需的任何状态.

My solution is to retain all of the special Facebook parameters through to the second page loaded into the IFRAME. Because you've interacted with it, cookies set on the second page will persist, and this allows your PHP code to keep whatever state it needs to communicate back to Facebook.

不过,这不太可能对您的 PHP 会话有帮助,因此我建议向第一页上的链接添加另一个参数,以允许第二页查找会话或以其他方式重新创建它.

This won't likely help your PHP session, though, so I suggest adding another parameter to links on the first page that allows the second page to look the session up, or otherwise recreate it.

这篇关于Safari 会话变量中具有多个页面的 Facebook Iframe 应用程序不持久的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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