--- title: Set-Cookie2 slug: Web/HTTP/Headers/Set-Cookie2 tags: - 废止 - 首部 translation_of: Web/HTTP/Headers/Set-Cookie2 ---
{{HTTPSidebar}} {{obsolete_header}}

Set-Cookie2 是一个响应首部,已废弃使用。它被服务器用来向客户端发送 cookie 数据,但是已经在协议中被标记为不赞成使用了。请使用 {{HTTPHeader("Set-Cookie")}}  将其代替。

Header type {{Glossary("Response header")}}
{{Glossary("Forbidden header name")}} no

语法

Set-Cookie2: <cookie-name>=<cookie-value>
Set-Cookie2: <cookie-name>=<cookie-value>; Comment=<value>
Set-Cookie2: <cookie-name>=<cookie-value>; CommentURL=<http-url>
Set-Cookie2: <cookie-name>=<cookie-value>; Discard
Set-Cookie2: <cookie-name>=<cookie-value>; Domain=<domain-value>
Set-Cookie2: <cookie-name>=<cookie-value>; Max-Age=<non-zero-digit>
Set-Cookie2: <cookie-name>=<cookie-value>; Path=<path-value>
Set-Cookie2: <cookie-name>=<cookie-value>; Port=<port-number>
Set-Cookie2: <cookie-name>=<cookie-value>; Secure
Set-Cookie2: <cookie-name>=<cookie-value>; Version=<version-number>

// Multiple directives are also possible, for example:
Set-Cookie2: <cookie-name>=<cookie-value>; Domain=<domain-value>; Secure

// Multiple cookies are seperated by a comma
Set-Cookie2: <cookie-name>=<cookie-value>, <cookie-name>=<cookie-value>, ...

规范

Specification Title
{{RFC("2965", "Set-Cookie2")}} Historic specification of HTTP State Management Mechanism, obsoleted by {{RFC("6265")}}

浏览器兼容性

{{Compat("http.headers.Set-Cookie2")}}

相关内容