【问题标题】:Can I use an <img> tag to send cookies across domains?我可以使用 <img> 标签跨域发送 cookie 吗?
【发布时间】:2010-09-28 22:17:16
【问题描述】:

看看这种情况:

  1. www.websitea.com 显示一个 img 标记,其 src 属性为 www.websiteb.com/image.aspx?id=5style="display:none"
  2. www.websiteb.com 返回一个清晰的图像,以及一个名称为 referrer 且值为 5 的 cookie(从经过验证的查询字符串创建的服务器端。)

cookie 会在域 www.websitea.comwww.websiteb.com 上创建吗?

目前,我确信使用查询字符串进行一系列重定向并实现跨域 cookie,但我不久前提出了这个图像想法。我想我也可以使用iframe

谢谢!

【问题讨论】:

    标签: cookies cross-domain


    【解决方案1】:

    将为 websiteb.com 创建 cookie。

    【讨论】:

      【解决方案2】:

      cookie 是根据对 websiteb.com 的请求创建的,所以是的...cookie 进入 websiteb 范围

      【讨论】:

        【解决方案3】:

        查看: cross-domain-user-tracking

        有人提到使用 1x1 图像进行跨域跟踪。

        【讨论】:

        • 我将此标记为答案,因为它最终解决了我的 ie6 问题
        【解决方案4】:

        好的,看起来不错。在所有浏览器中测试。为IE6添加了一个P3P标签,但不确定是否有必要。

        <%@ Page Language="VB" %>
        
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        
        <script runat="server">
            Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
                Response.AddHeader("P3P", "CP=""CAO PSA OUR""")
                Dim passedlocalizeID As String = Request.QueryString("id")
                Dim localizeID As Integer
                If passedlocalizeID IsNot Nothing AndAlso Int32.TryParse(passedlocalizeID, localizeID) Then
                    Dim localizer As New Localizer
                    localizer.LocalizeTo(localizeID)
                End If
            End Sub
        </script>
        
        <html xmlns="http://www.w3.org/1999/xhtml">
        <head runat="server">
            <title>Redirecting . . .</title>
            <meta http-equiv="refresh" content="0;URL=/" />
        </head>
        <body>
            <form id="form1" runat="server">
            <div>
            </div>
            </form>
        </body>
        </html>
        

        【讨论】:

          【解决方案5】:

          你在正确的轨道上。正如其他人所提到的,将为 websiteb.com 创建 cookie。

          要克服 IE 的问题,您可能需要宣传紧凑型隐私政策。

          从这里开始:http://msdn.microsoft.com/en-us/library/ms537342.aspx,其余的都在 Google 上。

          【讨论】:

            猜你喜欢
            • 2017-10-25
            • 1970-01-01
            • 1970-01-01
            • 2021-03-05
            • 1970-01-01
            • 2014-11-11
            • 1970-01-01
            • 2012-06-09
            • 2019-02-11
            相关资源
            最近更新 更多