Biwood
V2EX  ›  PHP

如何解决 Safari 浏览器中 iframe 嵌套的页面无法保存 cookie 的问题?

  •  
  •   Biwood · Aug 13, 2015 · 6224 views
    This topic created in 4015 days ago, the information mentioned may be changed or developed.
    Safari 的安全策略太严格了,iframe 嵌套的网站的 cookie 被认为是不安全的,因此不允许保存,这就导致了用户即使在 iframe 中登录了网站,也无法保持登录状态,每次跳转页面之后就需要重新登录。

    在网上搜了一圈,目前只看到一种解决办法:
    就是强行把 iframe 的父级页面跳转到子页面所在的网站,然后设置好 session ,再重定向到父级页面,这时候设置的 cookie 就被认为是安全的了。

    但是问题来了,我们的父级页面是一个静态 html 文件,只能在本地通过 file:// 协议打开,根本就不算是一个域名,所以也无法重定向过来,有没有什么办法能突破这种限制,使得 iframe 中的网站能够成功登录并保持登录状态?

    另外,我们的 html 页面是在 iOS 程序中打开的,能否通过 iOS 技术解决?
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2810 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 15:06 · PVG 23:06 · LAX 08:06 · JFK 11:06
    ♥ Do have faith in what you're doing.