博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
IE block my cookie in iframe
阅读量:6946 次
发布时间:2019-06-27

本文共 1540 字,大约阅读时间需要 5 分钟。

---恢复内容开始---

There is a severe bug that a leader figured it out in a published project.

In IE11, the page refreshs again and again, no contents are displayed.

I followed this problem and recorded it below:

Because of the IE security privacy policy, the cookie in the 3-party can't be allowed in IE. So my cookie is blocked and can't be set successfully.

I have found a wonderful blog that explanes the phenomeno and give the p3p privacy policy solution。

以下部分内容翻译自的《A Quick Look at P3P》

https://blogs.msdn.microsoft.com/ieinternals/2013/09/17/a-quick-look-at-p3p/

由于考虑有些网站通过iframe嵌套可能会跟踪你访问的站点,IE在对第三方cookie域会有网页隐私策略,所以限制和阻挡了cookie。

第三方cookie的定义:页面中通过不同的方式接收了不同域的url。不同方式例如:<script>, <img>, <link>, <frame>, <iframe>, <audio>, <video>以及包括设置了withCredentials标识的cross-domain XmlHttpRequest跨域请求。

在我的项目中涉及到子frame,示例:

IE9之前如果cookie被block了,会出现红眼睛进行提示,IE9(包括IE9)之后就不会出现红眼睛提示,并且console控制台也不报任何错误,可以通过 setting=》安全=》网页隐私策略进行查看:

 

 解决方案:

1.避免使用cookie存储

2.如果你避免不了,在3-party中HTTP的response header中设置P3P

如何设置?转载自宏宇转过来的文章(原谅我没找到原文的出处=.=)-- 

该文章有多重解决方案,我这里提取几种后台设置方案:

只需要设置 P3P HTTP Header,在隐含 iframe 里面跨域设置 cookie 就可以成功。他们所用的内容是:P3P: CP='CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR'ASP直接在头部加了头部申明,测试有效。<%Response.AddHeader "P3P", "CP=CAO PSA OUR"%>php的话,应该是如下写法:header('P3P: CP=CAO PSA OUR');ASP.NET的话通过在代码上加Response.AddHeader("P3P", "CP=CAO PSA OUR")或者在Window服务中将ASP.NET State Service 启动。JSP:response.setHeader("P3P","CP=CAO PSA OUR")

 

关于P3P的了解,请查看官网https://www.w3.org/P3P/

 

转载于:https://www.cnblogs.com/echo2016/p/8371678.html

你可能感兴趣的文章
JS调用命令实现F11全屏
查看>>
a标签href无值,点击刷新页面解决办法
查看>>
Arm开发板+Qt学习之路
查看>>
unknown local index 'index_name' in search request
查看>>
看视频学编程之C#中的类
查看>>
C# DataGridView控件绑定数据后清空数据
查看>>
C++基础知识(一)
查看>>
高抬贵手,拉耳复阳
查看>>
win2003 iis6 iis假死
查看>>
计算机网络知识总结
查看>>
poj 3844 Divisible Subsequences 剩余类,组合计数
查看>>
响应式布局这件小事
查看>>
子窗口访问父页面iframe中的iframe,top打开的子窗口访问父页面中的iframe中的iframe...
查看>>
css属性设置
查看>>
MongoDB -- JAVA基本API操作
查看>>
maven-reportng插件依赖添加
查看>>
树的存储结构实例
查看>>
typescript 的 polyfill 学习2-assign
查看>>
触发事件续
查看>>
python动态传参
查看>>