IE里Iframe的Cookie问题解决办法总结

compact policy header to your child content, and you can declare that no malicious actions are performed with the data of the user. If Internet Explorer detects a satisfactory policy, then Internet Explorer permits the cookie to be set.

Visit the following MSDN Web site for a complete list of satisfactory and unsatisfactory policy codes:

Privacy in Internet Explorer 6
http://msdn.microsoft.com/workshop/security/privacy/overview/privacyie6.asp (http://msdn.microsoft.com/workshop/security/privacy/overview/privacyie6.asp)

A simple compact policy that fulfills this criteria follows:

P3P: CP="CAO PSA OUR"

This code sample shows that your site provides you access to your own contact information (CAO), that any analyzed data is only "pseudo-analyzed", which means that the data is connected to your online persona and not to your physical identity (PSA), and that your data is not supplied to any outside agencies for those agencies to use (OUR).

You can set this header if you use the Response.AddHeader method in an ASP page. In ASP.NET, you can use the Response.AppendHeader method. You can use the IIS Management Snap-In (inetmgr) to add to a static file.

Follow these steps to add this header to a static file:

  1. Click Start, click Run, and then type inetmgr.
  2. In the left navigation page, click the appropriate file or directory in your Web site to which you want to add the header, right-click the file, and then click Properties.
  3. Click the HTTP Headers tab.
  4. In the Custom HTTP Headers group box, click Add.
  5. Type P3P for the header name, and then for the compact policy string, type CP=..., where "..." is the appropriate code for your compact policy.

Alternatively, Internet Explorer users can modify their privacy settings so that they are prompted to accept third party content. The following steps show how to modify the privacy settings:

  1. Run Internet Explorer.
  2. Click Tools, and then click Internet Options.
  3. Click the Privacy tab, and then click Advanced.
  4. Click to select the Override automatic cookie handling check box.
  5. To allow ASP and ASP.NET session cookies to be set, click to select the Always allow session cookies check box.
  6. To receive a prompt for any type of third party cookie, click Prompt in the Third-party Cookies list.
关于IE6 IFrame或Frame中读写cookie的问题分析

一、起因

信通宝在客户网站上浮动窗口的实现是通过在客户的网站上加上一段链接脚本,脚本在客户网站上写入一IFrame,此Iframe中的内容src=""是指向信通宝网站,如src="www.xtb.com/script.js"。 信通宝的功能需求中有一项是要求记录用户访问此网站的次数的,这就要求必须在访客的电脑中保存cookie才能实现。但是在IE6中,Frame和 IFrame中无法按常规方法来读写cookies。因为IE6加入了以PlatformforPrivacyPreferences(P3P)为基础的 隐私保护功能,有关此功能的说明请参阅“微软公布IE6新增隐私保护功能的详情

文章出处:http://hi.baidu.com/wuchangx
email:wuchang@guet.edu.cn

IE6中的隐私保护设置:
在“工具”菜单下选择“Internet选项”。点击“隐私”标签。IE 6的缺省隐私等级设置为“中”——即“阻止没有合同隐私策略的第三方cookie;阻止使用个人可标识信息而没有您的隐含许可的第三方cookie;限制使用个人可标识信息而没有隐含许可的第一方cookie”。见下图:

在ie6中Cookie被分成了first party cookie和third party cookie,即第一方Cookie和第三方Cookie,所谓的第三方Cookie是指在Frame或者Iframe中嵌套页面的Cookie。举例来 说,ABC公司购买了我们的信通宝产品,并在其公司网站http://www.abc.com/上加上了信通宝的链接脚本(www.xtb.com/test.js),这个脚本在abc公司的网站上加上一个IFrame,此Iframe的内容为xtb.com上的某个页面如(www.xtb.com/List.aspx?cid=1234),而这个List.aspx页面需要在读写cookie以便记录访客的次数等信息。当访客在访问ABC公司的网站时,http://www.abc.com/即为第一方站点,信通宝视为第三方站点,当List.aspx试图读写cookie时,IE6就会自动拦截(在状态栏下显示红色禁止图标),可以通过查看得到类似如下图的隐私报告:

以下是凌风现在使用的解决方法:
----------------------------------------------------
凌风(33446***) 09:28:58
信通宝代码在平台中可用部分之一:
//添加P3P到HTTP头输出流,用于解决IFrame下不能设置cookie的问题
Response.AddHeader("P3P", "CP=CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR");
凌风(3344***) 09:31:16
在IE下是不能在IFrame中设置cookie的,在FF下可以,但将以上代码拷贝到Page_Load中,即可解决该问题。  
---------------------------------------
此方法应用在信通宝第2版中,并通过测试。

二、P3P

什么是P3P?
P3P是万维网联盟(W3C)公布的一项隐私保护推荐标准,旨在为网上冲浪的Internet用户提供隐私保护。现在有越来越多的网站在消费者访问时,都 会收集一些用户信息。制定P3P标准的出发点就是为了减轻消费者因网站收集个人信息所引发的对于隐私权可能受到侵犯的忧虑。P3P标准的构想是:Web 站点的隐私策略应该告之访问者该站点所收集的信息类型、信息将提供给哪些人、信息将被保留多少时间及其使用信息的方式,如站点应做诸如 “本网站将监测您所访问的页面以提高站点的使用率”或“本网站将尽可能为您提供更合适的广告”等申明。访问支持P3P网站的用户有权查看站点隐私报告,然 后决定是否接受cookie或是否使用该网站。

访问官方P3P网页以获取更多技术信息:http://www.w3.org/P3P

三、相关技术文章

  1. Help! IE6 Is Blocking My Cookies[1][2]
    a).What is P3P?
    b).Why Does IE6 Block My Cookies?
    c).What are Third-Party Cookies?
    e).How Can I Prevent IE6 from Blocking My Cookies?
    f).How Do I P3P Enable My Web Site and Use Compact Policies?
    g).I P3P-Enabled My Site, But My Cookies are Still Being Blocked by IE6
    h).My Cookies aren't being Blocked, But Users are Not Able to View an i).IE6 Privacy Report for My Site
  2. The Platform for Privacy Preferences 1.0 Deployment Guide
  3. Make Your Web Site P3P Compliant
    此文通过6个简单的步骤介绍如何在网站上实施P3P策略。

四、“官方”的解决方法

看完了第三节的文章你会发现,所谓P3P策略实际就是一个部署在Web服务器上的简单XML文件,指明网站打算使用哪些cookie以及派什么用途。这个XML文件类似这种格式
<META xmlns="http://www.w3.org/2000/12/P3Pv1">
<POLICY-REFERENCES>
      <POLICY-REF about="/P3P/Policy1.xml">
          <COOKIE-INCLUDE
              name="*"
              value="*"
              domain="*"
              path="*"/>
      </POLICY-REF>
</POLICY-REFERENCES>
</META>
可以使用IBM的P3P策略编辑器
IBM's P3P Policy Editor来编写这个文件。

三种部署方式:

  1. Well-Know location
    /w3c/p3p.xml
    将P3P Reference File档案更名为p3p.xml,并放置在/w3c目录当中
  2. HTTP 头
    P3P:policyref="
    http://www.mysite.com/w3c/p3p.xml" CP="ALL DSP COR NID CUR OUR IND PUR"
    CP是由3字符代码组成的列表(相关信息已经在W3C网站上进行了说明)。在上例中,该网站不定期地(INDefinite)为OUR公司收集购买商品项 目(PURchasing)或完成当前活动(CURrent)的有关数据。有疑问(DiSPutes)、不可识别(Nonidentifiable)的数 据作为cookie存储(NID)。由于我们的网站以cookie的方式存储客户号,所以NID应该从列表中删除。
    CP应该匹配完整的策略;因此,如果你在CP中使用了NID,那么你应该在你的策略文件中包括<nonident/>标签。为了匹配这些设置 而在下一节介绍的校验工具会对以上代码进行检查,如果有差异的话,Internet Explorer 6.0浏览器也会检查策略文件并且令策略文件无效
    如果是asp/asp.net/jsp/php等动态页面,也可以添加类似以下代码:
    response.setHeader("P3P","policyref="
    http://www.mysite.com/w3c/p3p.xml" CP="ALL DSP COR CUR OUR IND PUR"");
  3. 在HTML内容中嵌入Link标签
    <link rel="P3Pv1" href="/w3c/p3p.xml"></link>

转自:http://www.cnblogs.com/cuihongyu3503319/archive/2009/05/12/1455063.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值