IE 不接受 iframe cookies (IE Blocking iFrame Cookies)

本文介绍了一种在Internet Explorer中解决第三方Cookie被阻止的方法,通过设置P3P Compact Policy头来确保会话ID正常传递,适用于PHP、ASP.NET、Django及JSP等不同后端技术。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


http://justcoding.iteye.com/blog/964679


I got a call today about one of my applications not running correctly from inside an iFrame. I tried it out and it looked like everything worked great in Safari and Firefox but not IE6 or IE7. It took me a few failed attempts to fix it before I decided it must be a session problem. After firing up a packet sniffer it became obvious the cookie with the session ID was not being passed.

 

The problem lies with a W3C standard called Platform for Privacy Preferences or P3P for short. You can read all about the boring stuff via the link or else just install the P3P Compact Policy header below. This will allow Internet Explorer to accept your third-party cookie. You will need to send the header on every page that sets a cookie.

 

PHP:

 

Php代码   收藏代码
  1. header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');  

 

ASP.NET:

 

Asp代码   收藏代码
  1. HttpContext.Current.Response.AddHeader("p3p","CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"");  
 

Django:

 

Django代码   收藏代码
  1. response = render_to_response('mytemplate.html')  
  2. response["P3P"] = 'CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"'  

 

JSP:

 

Jsp代码   收藏代码
  1. response.addHeader("P3P","CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"")  
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值