http-state Working Group | A. Barth |
Internet-Draft | U.C. Berkeley |
Intended status: Informational | December 22, 2009 |
Expires: June 25, 2010 |
This document defines the HTTP Cookie and Set-Cookie headers. ¶
This Internet-Draft is submitted to IETF in full conformance with the provisions of BCP 78 and BCP 79.¶
Internet-Drafts are working documents of the Internet Engineering Task Force (IETF), its areas, and its working groups. Note that other groups may also distribute working documents as Internet-Drafts.¶
Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as “work in progress”.¶
The list of current Internet-Drafts can be accessed at http://www.ietf.org/ietf/1id-abstracts.txt.¶
The list of Internet-Draft Shadow Directories can be accessed at http://www.ietf.org/shadow.html.¶
This Internet-Draft will expire on June 25, 2010.¶
Copyright (c) 2009 IETF Trust and the persons identified as the document authors. All rights reserved.¶
This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the BSD License.¶
This document may contain material from IETF Documents or IETF Contributions published or made publicly available before November 10, 2008. The person(s) controlling the copyright in some of this material may not have granted the IETF Trust the right to allow modifications of such material outside the IETF Standards Process. Without obtaining an adequate license from the person(s) controlling the copyright in such materials, this document may not be modified outside the IETF Standards Process, and derivative works of it may not be created outside the IETF Standards Process, except to format it for publication as an RFC or to translate it into languages other than English.¶
This document defines the HTTP Cookie and Set-Cookie header.¶
The following core rules are included by reference, as defined in [RFC5234], Appendix B.1: ALPHA (letters), CR (carriage return), CRLF (CR LF), CTL (controls), DIGIT (decimal 0-9), DQUOTE (double quote), HEXDIG (hexadecimal 0-9/A-F/a-f), LF (line feed), OCTET (any 8-bit sequence of data), SP (space), VCHAR (any visible [USASCII] character), and WSP (whitespace).¶
The terms user agent, client, server, proxy, and origin server have the same meaning as in the HTTP/1.0 specification.¶
Fully-qualified host name (FQHN) means either the fully-qualified domain name (FQDN) of a host (i.e., a completely specified domain name ending in a top-level domain such as .com or .uk), or the numeric Internet Protocol (IP) address of a host. The fully qualified domain name is preferred; use of numeric IP addresses is strongly discouraged. [TODO: What does "strongly discouraged" mean?]¶
The terms request-host and request-URI refer to the values the client would send to the server as, respectively, the host (but not port) and abs_path portions of the absoluteURI (http_URL) of the HTTP request line. Note that request-host must be a FQHN. Hosts names can be specified either as an IP address or a FQHN string.¶
Because it was used in Netscape's original implementation of state management, we will use the term cookie to refer to the state information that passes between an origin server and user agent, and that gets stored by the user agent.¶
We outline here a way for an origin server to send state information to the user agent, and for the user agent to return the state information to the origin server.¶
The origin server initiates a session, if it so desires, by including a Set-Cookie header in an HTTP response. (Note that "session" here does not refer to a persistent network connection but to a logical session created from HTTP requests and responses. The presence or absence of a persistent connection should have no effect on the use of cookie-derived sessions).¶
A user agent returns a Cookie request header (see below) to the origin server if it chooses to continue a session. The origin server may ignore it or use it to determine the current state of the session. It may send the client a Set-Cookie response header with the same or different information, or it may send no Set-Cookie header at all.¶
Servers may return a Set-Cookie response headers with any response. User agents should send Cookie request headers, subject to other rules detailed below, with every request.¶
An origin server may include multiple Set-Cookie headers in a response. Note that an intervening gateway MUST NOT fold multiple Set-Cookie headers into a single header.¶
[TODO: Overview the Set-Cookie and Cookie headers.]¶
[TODO: Put some examples here.¶
The cookie protocol consists of two HTTP headers: the Set-Cookie header and the Cookie header. The server sends the Set-Cookie header is to the user agent in an HTTP response, causing the user agent to modify the Cookie header it returns to the server.¶
This section describes the syntax and semantics of the protocol. Detailed conformance requirements for user agents are given in Section [TODO].¶
[TODO: Should we go into this much detail here? This seems redundant with the HTTP specs.]¶
An origin server must be cognizant of the effect of possible caching of both the returned resource and the Set-Cookie header. Caching "public" documents is desirable. For example, if the origin server wants to use a public document such as a "front door" page as a sentinel to indicate the beginning of a session for which a Set-Cookie response header must be generated, the page should be stored in caches "pre-expired" so that the origin server will see further requests. "Private documents", for example those that contain information strictly private to a session, should not be cached in shared caches.¶
If the cookie is intended for use by a single user, the Set-Cookie header should not be cached. A Set-Cookie header that is intended to be shared by multiple users may be cached.¶
The origin server should send the following additional HTTP/1.1 response headers, depending on circumstances: [TODO: Is this good advice?] ¶
and one of the following: ¶
HTTP/1.1 servers must send Expires: old-date (where old-date is a date long in the past) on responses containing Set-Cookie response headers unless they know for certain (by out of band means) that there are no downstream HTTP/1.0 proxies. HTTP/1.1 servers may send other Cache-Control directives that permit caching by HTTP/1.1 proxies in addition to the Expires: old-date directive; the Cache-Control directive will override the Expires: old-date for HTTP/1.1 proxies.¶
Not all origin servers conform to the behavior specified in the previous section. To ensure interoperability, user agents MUST process cookies in a manner that is "black-box" indistinguishable from the requirements in this section.¶
When the user agent receives a cookie, the user agent SHOULD record the cookie in its cookie store as follows.¶
A user agent MAY ignore received cookies in their entirety if the user agent is configured to block receiving cookie for a particular response. For example, the user agent might wish to block receiving cookies from "third-party" responses.¶
The user agent stores the following fields about each cookie: ¶
When the user agent receives a cookie, the user agent MUST follow the following algorithm: ¶
The user agent MUST evict a cookie from the cookie store if A cookie exists in the cookie store with an expiry date in the past.¶
The user agent MAY evict a cookie from the cookie store if the number of cookies sharing a domain field exceeds some predetermined upper bound (such as 50 cookies). [TODO: Explain where 50 comes from.]¶
The user agent MAY evict cookies from the cookie store if the cookie store exceeds some maximum storage bound (such as 3000 cookies). [TODO: Explain where 3000 comes from.]¶
When the user agent evicts cookies from the cookie store, the user agent MUST evict cookies in the following priority order: ¶
If two cookies have the same removal priority, the user agent MUST evict the cookie with the least recent last-access date first.¶
When "the current session is over", the user agent MUST remove from the cookie store all cookies with the persistent field set to false. ¶
Practical user agent implementations have limits on the number and size of cookies that they can store. General-use user agents SHOULD provide each of the following minimum capabilities: ¶
The information in a Set-Cookie response header must be retained in its entirety. If for some reason there is inadequate space to store the cookie, the cookie must be discarded, not truncated.¶
Applications should use as few and as small cookies as possible, and they should cope gracefully with the loss of a cookie. [TODO: Could mention latency issues that arise from having tons of cookies.]¶
The information in the Set-Cookie and Cookie headers is transmitted in the clear. Three consequences are: ¶
These facts imply that information of a personal and/or financial nature should be sent over a secure channel. For less sensitive information, or when the content of the header is a database key, an origin server should be vigilant to prevent a bad Cookie value from causing failures.¶
[TODO: Weak isolation by port.]¶
[TODO: Weak isolation by scheme (e.g., ftp, gopher, etc).]¶
[TODO: Describe relation to the Netscape Cookie Spec, RFC 2109, RFC 2629, and cookie-v2.]¶
This document borrows heavily from RFC 2109. [TODO: Figure out the proper way to credit the authors of RFC 2109.]¶
Tabled items: ¶