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

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

问题描述

我有一个具有多个PHP页面的Facebook Iframe应用程序。



我有一些链接指向我的iframe文件夹内的文件。 p>

iframe中的会话变量有一些问题。我设置了一些会话变量,但是它们不会从一个页面延伸到另一个页面。



这可以在其他浏览器上工作。



我一直在阅读,Safari不支持跨域Cookie,这可能是问题,但我不知道如何解决这个问题。



任何帮助?

解决方案

我写了

问题是Safari的默认行为是仅接受来自您访问的网站的Cookie。这不包括第三方Cookie。 Safari将IFRAME中的页面视为第三方网站,直到您与该内容进行交互(例如通过点击链接),它将拒绝这些Cookie。



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



我的解决方案是将所有特殊的Facebook参数保留到加载到IFRAME中的第二页。因为你已经与它进行了互动,所以在第二页上设置的cookies将会持续存在,这样你的PHP代码就可以保持任何需要的状态来回传Facebook。



不过,这不太可能有助于您的PHP会话,所以我建议在第一页的链接中添加另一个参数,允许第二页查看会话,或者重新创建它。


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

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

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.

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.

Any help?

解决方案

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

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.

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.

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.

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.

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

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