Unyablog.

のにれんのブログ

別のサブドメインの cookie をセットできるのか

できない。

疑問

  • foo.example.comDomain=bar.example.com をセットできるのか?
    • Domain=example.com はできる
    • Domain=example.net はできない

答え

できない。

The user agent will reject cookies unless the Domain attribute specifies a scope for the cookie that would include the origin server. For example, the user agent will accept a cookie with a Domain attribute of "example.com" or of "foo.example.com" from foo.example.com, but the user agent will not accept a cookie with a Domain attribute of "bar.example.com" or of "baz.foo.example.com".

RFC 6265 - HTTP State Management Mechanism