首页 文章

Cookie已阻止/未保存在Internet Explorer的IFRAME中

提问于
浏览
384

我有两个网站,让's say they' re example.comanotherexample.net . 在 anotherexample.net/page.html ,我有 IFRAME SRC="http://example.com/someform.asp" . IFRAME显示一个表单供用户填写并提交给 http://example.com/process.asp . 当我在自己的浏览器窗口中打开表单(“ someform.asp ”)时,一切正常 . 但是, when I load someform.asp as an IFRAME in IE 6 or IE 7, the cookies for example.com are not saved. 在Firefox中没有出现此问题 .

出于测试目的,我在http://newmoon.wz.cz/test/page.php上创建了类似的设置 .

example.com 使用基于cookie的会话(我无能为力),所以没有cookie, process.asp 将不会执行 . How do I force IE to save those cookies?

嗅探HTTP流量的结果:在GET /someform.asp响应中,有一个有效的每会话Set-Cookie头(例如 Set-Cookie: ASPKSJIUIUGF=JKHJUHVGFYTTYFY ),但在POST /process.asp请求中,根本没有Cookie头 .

Edit3:一些AJAX服务器端脚本显然能够回避问题,但这看起来非常像一个bug,而且它打开了一整套新的security holes . 我不容易 .

编辑: P3P policy was the root cause ,完整说明如下 .

22 回答

  • 163

    这是一个关于这个问题的一个很好的主题,但我发现一个重要的细节(至少在我的情况下是必不可少的)没有发布在这里或其他任何地方(我道歉,如果我错过了它)是P3P线必须是从第三方服务器发送的 EVERY 文件的 Headers 中传递,甚至文件未设置或使用诸如Javascript文件或图像之类的cookie . 否则cookie将被阻止 . 我在这里的帖子中有更多内容:http://posheika.net/?p=110

  • 3

    我得到了它的工作,但解决方案有点复杂,所以忍受我 .

    发生了什么事

    实际上,Internet Explorer对IFRAME页面的信任程度较低(IE称之为“第三方”内容) . 如果IFRAME中的页面没有隐私政策,则其cookie将被阻止(状态栏中的眼睛图标表示,当您单击它时,它会显示阻止的URL列表) .

    the evil eye http://stuff.piskvor.org/cookies_blocked_MSIE_eye.png

    在这种情况下,当cookie被阻止时,不会发送会话标识符,并且目标脚本会抛出“找不到会话”错误 .

    (我已经尝试将会话标识符设置为表单并从POST变量加载它 . This would have worked ,但出于政治原因,我不能这样做 . )

    可以使IFRAME中的页面更可信: if the inner page sends a P3P header with a privacy policy that is acceptable to IE, the cookies will be accepted .

    如何解决它

    创建p3p策略

    一个很好的起点是W3C tutorial . 我已经完成了它,下载了IBM Privacy Policy Editor并在那里我创建了一个隐私政策的代表,并给它一个名称来引用它(这里是 policy1 ) .

    NOTE :此时,您确实需要了解您的网站是否有隐私政策,如果没有,请创建它 - 是否收集用户数据,什么类型的数据,它对它有什么作用,谁有权访问它,等你需要找到这些信息并考虑一下 . Just slapping together a few tags will not cut it. 此步骤不能完全用软件完成,而且可能具有高度政治性(例如"should we sell our click statistics?") .

    (例如“该站点由ACME有限公司运营,它使用匿名的每会话标识符进行操作,仅在明确允许的情况下收集用户数据,并且仅出于以下目的,数据仅在必要时存储,仅限我们的公司可以访问它等 . “) .

    (使用此工具进行编辑时,可以查看策略中的错误/遗漏 . 另外非常有用的是“HTML政策”选项卡:在底部,它有一个“政策评估” - 快速检查政策是否会被阻止按IE的默认设置)

    编辑器导出到.p3p文件,该文件是上述策略的XML表示形式 . 此外,它可以导出此策略的“紧凑版本” .

    链接到该政策

    然后需要一个策略引用文件( http://example.com/w3c/p3p.xml )(该站点使用的隐私策略索引):

    <META>
      <POLICY-REFERENCES>
        <POLICY-REF about="/w3c/example-com.p3p#policy1">
          <INCLUDE>/</INCLUDE>
          <COOKIE-INCLUDE/>
        </POLICY-REF>
      </POLICY-REFERENCES>
    </META>
    

    <INCLUDE> 显示将使用此策略的所有URI(在我的情况下,整个站点) . 我从编辑器导出的策略文件已上传到 http://example.com/w3c/example-com.p3p

    发送包含响应的紧凑 Headers

    我在example.com上设置了webserver,发送带有响应的紧凑头,如下所示:

    HTTP/1.1 200 OK 
    P3P: policyref="/w3c/p3p.xml", CP="IDC DSP COR IVAi IVDi OUR TST"
    // ... other headers and content
    

    policyref 是策略引用文件的相对URI(后者又引用隐私策略), CP 是紧凑策略表示 . Note that the combination of P3P headers in the example may not be applicable on your specific website; your P3P headers MUST truthfully represent your own privacy policy!

    利润!

    在此配置中,Evil Eye不会出现,即使在IFRAME中也会保存Cookie,并且应用程序可以正常运行 .

    编辑:什么不该做,除非你喜欢为诉讼辩护

    有几个人建议“只需将一些标签贴在你的P3P Headers 上,直到邪恶的眼睛放弃” .

    标签不仅是一堆,它们有 real world meanings ,它们的使用给你 real world responsibilities

    例如,假装您从不收集用户数据可能会使浏览器满意,但如果您实际收集用户数据,则P3P与现实冲突 . 简单明了,这可能是某些国家的犯罪行为 . 如,"go to jail, do not collect $200" .

    几个例子(see p3pwriter for the full set of tags):

    • NOI :"Web Site does not collected identified data."(只要有任何自定义,登录或任何数据收集(***** Analytics,任何人?),您 must 在您的P3P中确认它)

    • STP :保留信息以满足规定的目的 . 这要求尽可能早地丢弃信息 . 站点必须具有 Build 销毁时间表的保留策略 . 保留政策必须包含在网站的人类可读隐私政策中或与之相关联 . “(如果您发送 STP 但没有保留政策,您可能正在进行欺诈 . 多么酷啊?一点也不 . )

    我不愿意去法院看看P3P Headers 是否真的具有法律约束力,或者你是否可以向用户承诺任何事情而不愿意兑现你的承诺 .

  • 2

    我花了很大一部分时间来研究这个P3P的事情,我觉得有必要分享我发现的东西 .

    我注意到P3P概念已经过时,似乎只是由Internet Explorer(IE)真正使用/强制执行 .

    最简单的解释是:如果您使用cookie,IE希望您定义P3P标头 .

    这是一个不错的主意,幸运的是大多数时候不提供此 Headers 不会导致任何问题(阅读浏览器警告) . 除非您的网站/网络应用程序使用(i)框架加载到其他网站 . 这就是IE成为***的巨大痛苦的地方 . 除非设置了P3P标头,否则它不允许您设置cookie .

    知道了这一点,我想找到以下两个问题的答案:

    • 谁在乎?换句话说,如果我在 Headers 中加上单词"Potato",我可以被起诉吗?

    • 其他公司做什么?

    我的发现是:

    • 无人问津 . 我找不到世界上一个采用法律阻止你在P3P Headers 中加入单词"Potato"的国家/地区

    • 谷歌和Facebook都在他们的P3P Headers 字段中放置了一个链接,引用了一个页面,描述了他们没有P3P Headers 的原因 .

    这个概念诞生于2002年,令我感到困惑的是,这个过时的,法律上未实现的概念仍然强加于IE中的开发人员 . 如果此标头没有任何合法的后果,则应忽略此标头(或者,在控制台中生成警告或通知) . 没有强制执行!我现在被迫在我的代码中添加一行(并向客户端发送一个 Headers ),它绝对没有任何作用 .

    简而言之 - 保持IE的快乐 - 在PHP代码中添加以下行(其他语言应该类似)

    header('P3P: CP="Potato"');
    

    问题解决了,IE很满意这个土 beans .

  • 1

    通过简单地将这个小 Headers 添加到IFrame(PHP解决方案)中的网站,我就能够消除邪恶之眼:

    header('P3P: CP="NOI ADM DEV COM NAV OUR STP"');
    

    Remember to press ctrl+F5 重新加载您的网站或资源管理器可能仍然显示邪恶的眼睛,尽管它的工作正常 . 这可能是我遇到这么多问题的主要原因 .

    根本没有必要的政策文件 .

    编辑:我发现了一个很好的博客文章,解释了IFrame中的cookie问题 . 它还可以快速修复C#代码:Frames, ASPX Pages and Rejected Cookies

  • 1

    这隐藏在其他答案的评论中,但我差点错过了,所以看起来它应该得到自己的答案 .

    要查看:为了让IE接受第三方cookie,您需要使用名为p3p的http标头以下列格式提供文件:

    CP="my compact p3p policy"
    

    但是,p3p在这一点上已经非常死了,你可以轻松地让IE工作,而无需投入时间和法律资源来创建真正的p3p策略 . 这是因为如果您的压缩p3p策略标头无效,IE实际上将其视为一个好的策略并接受第三方cookie . 所以你可以使用像这样的p3p头

    CP="This site does not have a p3p policy."
    

    你可以选择包含一个页面链接,解释为什么你没有p3p政策,就像谷歌和Facebook那样(他们指的是:https://support.google.com/accounts/answer/151657和这里:https://www.facebook.com/help/327993273962160/) .

    最后,重要的是要注意从第三方站点提供的所有文件都需要有p3p标头,而不仅仅是设置cookie的文件,因此您可能无法在PHP,asp.net等中执行此操作 . 码 . 您可能最好在Web服务器级别(即在IIS或Apache中)进行设置 .

  • 5

    我也有这个问题,以为我'd post the code that I used in my MVC2 project. Be careful when in the page life cycle you add in the header or you'会得到一个HttpException“ Server cannot append header after HTTP headers have been sent ” . 我在OnActionExecuting方法上使用了自定义ActionFilterAttribute(在执行操作之前调用) .

    /// <summary>
    /// Privacy Preferences Project (P3P) serve a compact policy (a "p3p" HTTP header) for all requests
    /// P3P provides a standard way for Web sites to communicate about their practices around the collection, 
    /// use, and distribution of personal information. It's a machine-readable privacy policy that can be 
    /// automatically fetched and viewed by users, and it can be tailored to fit your company's specific policies.
    /// </summary>
    /// <remarks>
    /// More info http://www.oreillynet.com/lpt/a/1554
    /// </remarks>
    public class P3PAttribute : ActionFilterAttribute
    {
        /// <summary>
        /// On Action Executing add a compact policy "p3p" HTTP header
        /// </summary>
        /// <param name="filterContext"></param>
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            HttpContext.Current.Response.AddHeader("p3p","CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"");
    
            base.OnActionExecuting(filterContext);
        }
    }
    

    使用示例:

    [P3P]
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewData["Message"] = "Welcome!";
    
            return View();
        }
    
        public ActionResult About()
        {
            return View();
        }
    }
    
  • 21

    任何在node.js中遇到此问题的人 .

    然后添加此p3p模块,并在中间件上启用此模块 .

    npm install p3p
    

    我正在使用快递,所以我在app.js中添加它

    首先要求app.js中的模块

    var express = require('express');
    var app = express();
    var p3p = require('p3p');
    

    然后用它作为中间件

    app.use(p3p(p3p.recommended));
    

    它将在res对象中添加p3p标头 . 不需要做任何额外的事情 .

    您将获得更多信息:

    https://github.com/troygoode/node-p3p

  • 5

    如果有人在寻找Apache系列;我们用过这个 .

    Headers 集P3P“CP = \”谢谢IE8 \“”

    只要有P3P Headers ,我们将CP值设置为什么并不重要 .

  • 55

    一个可能的做法是将域添加到工具中允许的站点 - >互联网选项 - >隐私 - >网站:somedomain.com - >允许 - >好的 .

  • 0

    This post提供了一些关于P3P的评论和一个简化的解决方案,可以减少IE7和IE8的问题 .

  • 1

    我在这里没有提到的一个解决方案是使用session storage而不是cookie . 当然,这可能不适合每个人's requirements, but for some cases it'一个简单的解决方案 .

  • 1

    我正在调查有关通过Azure Access Control Services登录的问题,并且无法连接任何内容的正面和尾部 .

    然后,偶然发现了这篇文章https://blogs.msdn.microsoft.com/ieinternals/2011/03/10/beware-cookie-sharing-in-cross-zone-scenarios/

    简而言之,IE不跨区域共享cookie(例如,Internet与可信站点) .

    因此,如果你的IFrame目标和html页面位于不同的区域,P3P对任何事情都无济于事 .

  • 0

    有类似的问题,也去调查今天早上如何生成P3P策略,这里是关于如何生成自己的策略并在网站上使用的帖子:) http://everydayopenslikeaflower.blogspot.com/2009/08/how-to-create-p3p-policy-and-implement.html

  • 0

    我之前已经实施了完整的P3P政策,但不想再为我正在开展的新项目解决麻烦 . 我发现此链接对于问题的简单解决方案很有用,只需指定“CAO PSA OUR”的最小紧凑P3P策略:

    http://blog.sweetxml.org/2007/10/minimal-p3p-compact-policy-suggestion.html

    该文引用了一个(现已破碎)链接到Microsoft kb文章 . 政策为我做了诀窍!

  • 14

    您还可以将p3p.xml和policy.xml文件组合在一起:

    /home/ubuntu/sites/shared/w3c/p3p.xml

    <META xmlns="http://www.w3.org/2002/01/P3Pv1">
      <POLICY-REFERENCES>
        <POLICY-REF about="#policy1">
          <INCLUDE>/</INCLUDE>
          <COOKIE-INCLUDE/>
        </POLICY-REF>
      </POLICY-REFERENCES>
      <POLICIES>
        <POLICY discuri="" name="policy1">
          <ENTITY>
            <DATA-GROUP>
              <DATA ref="#business.name"></DATA> 
              <DATA ref="#business.contact-info.online.email"></DATA> 
            </DATA-GROUP>
          </ENTITY>
          <ACCESS>
            <nonident/>
          </ACCESS>
          <!-- if the site has a dispute resolution procedure that it follows, a DISPUTES-GROUP should be included here -->
          <STATEMENT>
            <PURPOSE>
              <current/>
              <admin/>
              <develop/>
            </PURPOSE>
            <RECIPIENT>
              <ours/>
            </RECIPIENT>
            <RETENTION>
              <indefinitely/>
            </RETENTION>
            <DATA-GROUP>
              <DATA ref="#dynamic.clickstream"/>
              <DATA ref="#dynamic.http"/>
            </DATA-GROUP>
          </STATEMENT>
        </POLICY>
      </POLICIES>
    </META>
    

    我发现添加标头的最简单方法是通过Apache代理并使用mod_headers,如下所示:

    <VirtualHost *:80>
      ServerName mydomain.com
    
      DocumentRoot /home/ubuntu/sites/shared/w3c/
    
      ProxyRequests off
      ProxyPass /w3c/ !
      ProxyPass / http://127.0.0.1:8080/
      ProxyPassReverse / http://127.0.0.1:8080/
      ProxyPreserveHost on
    
      Header add p3p 'P3P:policyref="/w3c/p3p.xml", CP="NID DSP ALL COR"'
    </VirtualHost>
    

    因此我们将除了/w3c/p3p.xml之外的所有请求代理到我们的应用服务器 .

    您可以使用W3C validator进行全部测试

  • 3

    If you own the domain that needs to be embedded ,那么你可以在调用包含IFrame的页面之前,重定向到该域,这将创建cookie并重定向回来,如下所述:http://www.mendoweb.be/blog/internet-explorer-safari-third-party-cookie-problem/

    这适用于Internet Explorer,但也适用于Safari(因为Safari也会阻止第三方cookie) .

  • 425

    我知道我在这个问题上做出贡献有点晚了,但我失去了很多时间,也许这个答案对某些人有帮助 .

    我试图在我的网站上调用第三方cookie,当然即使在安全级别较低的情况下它也无法在Internet Explorer 10上运行...不要问我原因 . 在iframe中,我用ajax调用了read_cookie.php(echo $ _COOKIE) .

    我不知道为什么我无法设置P3P政策来解决问题......

    在我的搜索过程中,我看到了一些关于在JSON中使用cookie的工作 . 我甚至没有尝试,因为我认为如果cookie不会通过iframe,它将不再通过数组...

    猜猜看是什么!因此,如果你对你的cookie进行json_encode,那么在你的ajax请求之后解码,你就会得到它!

    也许有一些我错过的东西,如果我这样做,我所有的道歉,但我从未见过如此愚蠢的东西 . 为安全起见阻止第三方cookie,为什么不,但如果编码则让它通过?安全现在在哪里?

    我希望这篇文章会对某人有所帮助,如果我错过了一些东西而且我很蠢,请教育我!

  • 3

    这最终对我有用(经过大量的hastle并使用IBM的策略生成器生成一些策略) . 您可以在此处下载策略生成器:http://www.softpedia.com/get/Security/Security-Related/P3P-Policy-Editor.shtml

    我无法再从官方IBM网站下载该生成器 .

    我在Web-App的根文件夹中创建了这些文件

    /index.php
    /w3c/policy.html (Human readable format)
    /w3c/p3p.xml
    /w3c/policy.p3p
    
    • Index.php:只需发送一个额外的 Headers :
    header('P3P: policyref="/w3c/p3p.xml", CP="ALL DSP NID CURa ADMa DEVa HISa OTPa OUR NOR NAV DEM"');
    
    • p3p.xml的内容
    <META>
        <POLICY-REFERENCES>
            <POLICY-REF about="/w3c/policy.p3p#App">
                <INCLUDE>/</INCLUDE>
                <COOKIE-INCLUDE/>
            </POLICY-REF>
        </POLICY-REFERENCES>
    </META>
    
    • 我的policy.html文件的内容
    <html>
    <head>
    <STYLE type="text/css">
    title { color: #3333FF}
    </STYLE>
    <title>Privacy Statement for YOUR COMPANY NAME</title>
    </head>
    <body>
    <h1 class="title">Privacy Policy</h1>
    <!-- "About Us" section of privacy policy -->
    <h2>About Us</h2>
    <p>This is a privacy policy for YOUR COMPANY NAME.
    Our homepage on the Web is located at <a href="YOURWEBSITE">
    YOURWEBSITE</a>.
    The full text of our privacy policy is available on the Web at 
    <a href="ABSOLUTE URL OF THIS FILE">
    ABSOLUTE URL OF THIS FILE</a>
    This policy does not tell users where they can go to exercise their opt-in or opt-out options.
    <p>We invite you to contact us if you have questions about this policy.
    You may contact us by mail at the following address:
    <pre>FIRSTNAME LASTNAME
    YOUR ADDRESS HERE
    </pre>
    <p>You may contact us by e-mail at 
    <a href="mailto:info@YOURMAIL.de">
    info@YOURMAIL.eu</a>. 
    You may call us at TELEPHONENUMBER.
    <!-- "Privacy Seals" section of privacy policy -->
    <h2>Dispute Resolution and Privacy Seals</h2>
    <p>We have the following privacy seals and/or dispute resolution mechanisms.
    If you think we have not followed our privacy policy in some way, they can help you resolve your concern.
    <ul>
    <li>
    <b>Dispute</b>:
    Contact us for further information
    </ul>
    <!-- "Additional information" section of privacy policy -->
    <h2>Additional Information</h2>
    <p>
    This policy is valid for 1 day from the time that it is loaded by a client.
    </p>
    <!-- "Data Collection" section of privacy policy -->
    <h2>Data Collection</h2>
    <p>P3P policies declare the data they collect in groups (also referred to as "statements").
    This policy contains 1 data group.
    <hr width="50%" align="center">
    <h3>Group "App control data"</h3>
    <p>We collect the following information:
    <ul>
    <li>HTTP cookies</li>
    </ul>
    <p>This data will be used for the following purposes:</p>
    <ul>
    <li>Completion and support of the current activity.</li>
    <li>Web site and system administration.</li>
    <li>Research and development.</li>
    <li>Historical preservation.</li>
    <li>Other purposes<p>Control Flow of the application</p></li>
    </ul>
    <p>This data will be used by ourselves and our agents.
    <p>The data in this group has been marked as non-identifiable. This means that there is no
    reasonable way for the site to identify the individual person this data was collected from.
    <p>The following explanation is provided for why this data is collected:</p>
    <blockquote>This cookie data is only used to control the application within an iframe (e.g. a Facebook App)</blockquote>
    <!-- "Use of Cookies" section of privacy policy -->
    <hr width="50%" align="center">
    <h2>Cookies</h2>
    <p>Cookies are a technology which can be used to provide you with tailored information from a Web site. A cookie is an element of data that a Web site can send to your browser, which may then store it on your system. You can set your browser to notify you when you receive a cookie, giving you the chance to decide whether to accept it.
    <p>Our site makes use of cookies.
    Cookies are used for the following purposes:
    <ul>
    <li>Site administration
    <li>Completing the user's current activity
    <li>Research and development
    <li>Other
    (Control Flow of the application)
    </ul>
    <!-- "Compact Policy Explanation" section of privacy policy -->
    <hr width="50%" align="center">
    <h2>Compact Policy Summary</h2>
    <p>The compact policy which corresponds to this policy is:
    <pre>
        CP="ALL DSP NID CURa ADMa DEVa HISa OTPa OUR NOR NAV"
    </pre>
    <p>The following table explains the meaning of each field in the compact policy.
    <center><table width="80%" border="1" cols="2">
    <tr><td align="center" valign="top" width="20%"><b>Field</b></td><td align="center" valign="top" width="80%"><b>Meaning</b></td></tr>
    <tr><td align="left" valign="top" width="20%"><tt>CP=</tt></td>
    <td align="left" valign="top" width="80%">This is the compact policy header; it indicates that what follows is a P3P compact policy.</td></tr>
    <tr><td align="left" valign="top" width="20%"><tt>ALL</tt></td>
    <td align="left" valign="top" width="80%">
    Access to all collected information is available.
    </td></tr>
    <tr><td align="left" valign="top" width="20%"><tt>DSP</tt></td>
    <td align="left" valign="top" width="80%">
    The policy contains at least one dispute-resolution mechanism.
    </td></tr>
    <tr><td align="left" valign="top" width="20%"><tt>NID</tt></td>
    <td align="left" valign="top" width="80%">
    The information collected is not personally identifiable.
    </td></tr>
    <tr><td align="left" valign="top" width="20%"><tt>CURa</tt></td>
    <td align="left" valign="top" width="80%">
    The data is used for completion of the current activity.
    </td></tr>
    <tr><td align="left" valign="top" width="20%"><tt>ADMa</tt></td>
    <td align="left" valign="top" width="80%">
    The data is used for site administration.
    </td></tr>
    <tr><td align="left" valign="top" width="20%"><tt>DEVa</tt></td>
    <td align="left" valign="top" width="80%">
    The data is used for research and development.
    </td></tr>
    <tr><td align="left" valign="top" width="20%"><tt>HISa</tt></td>
    <td align="left" valign="top" width="80%">
    The data is used for historical archival purposes.
    </td></tr>
    <tr><td align="left" valign="top" width="20%"><tt>OTPa</tt></td>
    <td align="left" valign="top" width="80%">
    The data is used for other purposes.
    </td></tr>
    <tr><td align="left" valign="top" width="20%"><tt>OUR</tt></td>
    <td align="left" valign="top" width="80%">
    The data is given to ourselves and our agents.
    </td></tr>
    <tr><td align="left" valign="top" width="20%"><tt>NOR</tt></td>
    <td align="left" valign="top" width="80%">
    The data is not kept beyond the current transaction.
    </td></tr>
    <tr><td align="left" valign="top" width="20%"><tt>NAV</tt></td>
    <td align="left" valign="top" width="80%">
    Navigation and clickstream data is collected.
    </td></tr>
    </table></center>
    <p>The compact policy is sent by the Web server along with the cookies it describes.
    For more information, see the P3P deployment guide at <a href="http://www.w3.org/TR/p3pdeployment">http://www.w3.org/TR/p3pdeployment</a>.
    <!-- "Policy Evaluation" section of privacy policy -->
    <hr width="50%" align="center">
    <h2>Policy Evaluation</h2>
    <p>Microsoft Internet Explorer 6 will evaluate this policy's compact policy whenever it is used with a cookie.
    The actions IE will take depend on what privacy level the user has selected in their browser (Low, Medium, Medium High, or High; the default is Medium.
    In addition, IE will examine whether the cookie's policy is considered satisfactory or unsatisfactory, whether the cookie is a session cookie or a persistent cookie, and whether the cookie is used in a first-party or third-party context.
    This section will attempt to evaluate this policy's compact policy against Microsoft's stated behavior for IE6.
    <p><b>Note:</b> this evaluation is currently experimental and should not be considered a substitute for testing with a real Web browser.
    <p><b>Satisfactory policy</b>: this compact policy is considered <em>satisfactory</em> according to the rules defined by Internet Explorer 6.
    IE6 will accept cookies accompanied by this policy under the High, Medium High, Medium, Low, and Accept All Cookies settings.
    </body></html>
    
    • policy.p3p的内容
    <?xml version="1.0"?>
    <POLICIES xmlns="http://www.w3.org/2002/01/P3Pv1">
        <!-- Generated by IBM P3P Policy Editor version Beta 1.12 built 2/27/04 1:19 PM -->
    
        <!-- Expiry information for this policy -->
        <EXPIRY max-age="86400"/>
    
    <POLICY
        name="App"
        discuri="ABSOLUTE URL TO policy.html"
        xml:lang="de">
        <!-- Description of the entity making this policy statement. -->
        <ENTITY>
        <DATA-GROUP>
    <DATA ref="#business.name">COMPANY NAME</DATA>
    <DATA ref="#business.contact-info.online.email">info@YOURMAIL.eu</DATA>
    <DATA ref="#business.contact-info.online.uri">YOURWEBSITE</DATA>
    <DATA ref="#business.contact-info.telecom.telephone.number">YOURPHONENUMBER</DATA>
    <DATA ref="#business.contact-info.postal.organization">FIRSTNAME LASTNAME</DATA>
    <DATA ref="#business.contact-info.postal.street">STREET</DATA>
    <DATA ref="#business.contact-info.postal.city">CITY</DATA>
    <DATA ref="#business.contact-info.postal.stateprov">STAGE</DATA>
    <DATA ref="#business.contact-info.postal.postalcode">POSTALCODE</DATA>
    <DATA ref="#business.contact-info.postal.country">Germany</DATA>
        </DATA-GROUP>
        </ENTITY>
    
        <!-- Disclosure -->
        <ACCESS><all/></ACCESS>
    
    
        <!-- Disputes -->
        <DISPUTES-GROUP>
            <DISPUTES resolution-type="service" service="YOURWEBSITE CONTACT FORM" short-description="Dispute">
                <LONG-DESCRIPTION>Contact us for further information</LONG-DESCRIPTION>
        <!-- No remedies specified -->
            </DISPUTES>
        </DISPUTES-GROUP>
    
        <!-- Statement for group "App control data" -->
        <STATEMENT>
            <EXTENSION optional="yes">
                <GROUP-INFO xmlns="http://www.software.ibm.com/P3P/editor/extension-1.0.html" name="App control data"/>
            </EXTENSION>
    
        <!-- Consequence -->
        <CONSEQUENCE>
    This cookie data is only used to control the application within an iframe (e.g. a Facebook App)</CONSEQUENCE>
    
        <!-- Data in this statement is marked as being non-identifiable -->
        <NON-IDENTIFIABLE/>
    
        <!-- Use (purpose) -->
        <PURPOSE><admin/><current/><develop/><historical/><other-purpose>Control Flow of the application</other-purpose></PURPOSE>
    
        <!-- Recipients -->
        <RECIPIENT><ours/></RECIPIENT>
    
        <!-- Retention -->
        <RETENTION><no-retention/></RETENTION>
    
        <!-- Base dataschema elements. -->
        <DATA-GROUP>
        <DATA ref="#dynamic.cookies"><CATEGORIES><navigation/></CATEGORIES></DATA>
        </DATA-GROUP>
    </STATEMENT>
    
    <!-- End of policy -->
    </POLICY>
    </POLICIES>
    
  • 2

    在Rails中我正在使用这个gem:https://github.com/merchii/rack-iframe从本质上讲,它设置了一组没有引用文件的缩写:https://github.com/merchii/rack-iframe/blob/master/lib/rack/iframe.rb#L8

    当你完全不关心p3p的含义时,它很容易安装 .

  • 4

    对于任何试图让P3P Compact Policy使用静态内容的人:

    如果您能够使用静态内容发送自定义服务器端响应标头,则可能是 only .

    有关更详细的说明,请参阅我的答案:Set P3P code in HTML

  • 20

    在Rails 3.2中我使用:

    class ApplicationController < ActionController::Base  
    
      before_filter :set_p3p  
    
      private  
        # for IE session cookies thru iframe  
        def set_p3p  
          headers['P3P'] = 'CP="ALL DSP COR CURa ADMa DEVa OUR IND COM NAV"'  
        end  
    end
    

    我得到了这个:http://dot-net-web-developer-bristol.blogspot.com/2012/04/setting-p3p-header-in-rails-session.html

  • -1

    一个更好的解决方案是在iframe内部进行Ajax调用,以获取/设置cookie ...

相关问题