【问题标题】:Is there any way to set cookie to all the sub-domains of a domain (Domain=.site.com) but exclude just 1 domain?有没有办法将 cookie 设置为域的所有子域(域 = .site.com)但只排除 1 个域?
【发布时间】:2019-11-15 16:58:34
【问题描述】:

我们正在通过 CNAME 记录将我们的一个子域 (sub.site1.com) 指向第三方应用程序 (app.site2.com)。我不想将用户 cookie 发送到他们的服务器。除了 sub.site1.com 之外,有没有办法为我们所有的子域设置 cookie?请帮忙。

我尝试了不同的 Set-Cookie 与域规范的变体。

【问题讨论】:

  • .site1.com 的 cookie 不会在请求中发送到 app.site2.com -- 这是 2 个不同的域。
  • 正如我提到的,sub.site1.com 通过 CNAME 记录指向 app.site2.com。对于浏览器 sub.site1.com 是一个有效的子域来做 Domain=.site1.com

标签: http web https http-headers


【解决方案1】:

很遗憾,这是不可能的。

根据RFC6265(描述cookie的RFC),cookie域的syntax是:

domain-av         = "Domain=" domain-value
domain-value      = <subdomain>
                       ; defined in [RFC1034], Section 3.5, as
                       ; enhanced by [RFC1123], Section 2.1

那么,根据RFC1034RFC1123,cookie中可以使用的域不支持任何复杂的语法。没有办法排除一个子域同时支持所有其他子域。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-07-12
    • 2012-08-25
    • 2017-07-30
    • 1970-01-01
    • 2011-04-23
    • 2021-06-25
    • 2015-12-05
    相关资源
    最近更新 更多