As per Relevance of the word mechanism, we have this rfc below:











Network Working Group D.
Request for Comments: 2109 Bell Laboratories, Lucent
Category: Standards Track L.
Netscape
February 1997


HTTP State Management

Status of this

This document specifies an Internet standards track protocol for
Internet community, and requests discussion and suggestions
improvements. Please refer to the current edition of the "
Official Protocol Standards" (STD 1) for the standardization
and status of this protocol. Distribution of this memo is unlimited

1.

This document specifies a way to create a stateful session with
requests and responses. It describes two new headers, Cookie
Set-Cookie, which carry state information between
origin servers and user agents. The method described here
from Netscape's Cookie proposal, but it can interoperate
HTTP/1.0 user agents that use Netscape's method. (See the
section.)

2.

The terms user agent, client, server, proxy, and origin server
the same meaning as in the HTTP/1.0 specification

Fully-qualified host name (FQHN) means either the fully-
domain name (FQDN) of a host (i.e., a completely specified
name ending in a top-level domain such as .com or .uk), or
numeric Internet Protocol (IP) address of a host. The
qualified domain name is preferred; use of numeric IP addresses
strongly discouraged

The terms request-host and request-URI refer to the values the
would send to the server as, respectively, the host (but not port
and abs_path portions of the absoluteURI (http_URL) of the
request line. Note that request-host must be a FQHN








Kristol & Montulli Standards Track [Page 1]

RFC 2109 HTTP State Management Mechanism February 1997


Hosts names can be specified either as an IP address or a
string. Sometimes we compare one host name with another. Host A'
name domain-matches host B's

* both host names are IP addresses and their host name strings
exactly;

* both host names are FQDN strings and their host name strings
exactly;

* A is a FQDN string and has the form NB, where N is a non-empty
string, B has the form .B', and B' is a FQDN string. (So, x.y.
domain-matches .y.com but not y.com.)

Note that domain-match is not a commutative operation: a.b.c.
domain-matches .c.com, but not the reverse

Because it was used in Netscape's original implementation of
management, we will use the term cookie to refer to the
information that passes between an origin server and user agent,
that gets stored by the user agent

3. STATE AND

This document describes a way to create stateful sessions with
requests and responses. Currently, HTTP servers respond to
client request without relating that request to previous
subsequent requests; the technique allows clients and servers
wish to exchange state information to place HTTP requests
responses within a larger context, which we term a "session".
context might be used to create, for example, a "shopping cart",
which user selections can be aggregated before purchase, or
magazine browsing system, in which a user's previous reading
which offerings are presented

There are, of course, many different potential contexts and thus
different potential types of session. The designers' paradigm
sessions created by the exchange of cookies has these key attributes

1. Each session has a beginning and an end

2. Each session is relatively short-lived

3. Either the user agent or the origin server may terminate
session

4. The session is implicit in the exchange of state information




Kristol & Montulli Standards Track [Page 2]

RFC 2109 HTTP State Management Mechanism February 1997


4.

We outline here a way for an origin server to send state
to the user agent, and for the user agent to return the
information to the origin server. The goal is to have a
impact on HTTP and user agents. Only origin servers that need
maintain sessions would suffer any significant impact, and
impact can largely be confined to Common Gateway Interface (CGI
programs, unless the server provides more sophisticated
management support. (See Implementation Considerations, below.)

4.1 Syntax:

The two state management headers, Set-Cookie and Cookie, have
syntactic properties involving attribute-value pairs. The
grammar uses the notation, and tokens DIGIT (decimal digits)
token (informally, a sequence of non-special, non-white
characters) from the HTTP/1.1 specification [RFC 2068] to
their syntax

av-pairs = av-pair *(";" av-pair
av-pair = attr ["=" value] ; optional
attr =
value =
word = token | quoted-

Attributes (names) (attr) are case-insensitive. White space
permitted between tokens. Note that while the above
description shows value as optional, most attrs require them

NOTE: The syntax above allows whitespace between the attribute
the = sign

4.2 Origin Server

4.2.1

The origin server initiates a session, if it so desires. (Note
"session" here does not refer to a persistent network connection
to a logical session created from HTTP requests and responses.
presence or absence of a persistent connection should have no
on the use of cookie-derived sessions). To initiate a session,
origin server returns an extra response header to the client, Set
Cookie. (The details follow later.)

A user agent returns a Cookie request header (see below) to
origin server if it chooses to continue a session. The origin
may ignore it or use it to determine the current state of



Kristol & Montulli Standards Track [Page 3]

RFC 2109 HTTP State Management Mechanism February 1997


session. It may send back to the client a Set-Cookie response
with the same or different information, or it may send no Set-
header at all. The origin server effectively ends a session
sending the client a Set-Cookie header with Max-Age=0.

Servers may return a Set-Cookie response headers with any response
User agents should send Cookie request headers, subject to
rules detailed below, with every request

An origin server may include multiple Set-Cookie headers in
response. Note that an intervening gateway could fold multiple
headers into a single header

4.2.2 Set-Cookie

The syntax for the Set-Cookie response header

set-cookie = "Set-Cookie:"
cookies = 1#
cookie = NAME "=" VALUE *(";" cookie-av
NAME =
VALUE =
cookie-av = "Comment" "="
| "Domain" "="
| "Max-Age" "="
| "Path" "="
| "Secure
| "Version" "=" 1*

Informally, the Set-Cookie response header comprises the token Set
Cookie:, followed by a comma-separated list of one or more cookies
Each cookie begins with a NAME=VALUE pair, followed by zero or
semi-colon-separated attribute-value pairs. The syntax
attribute-value pairs was shown earlier. The specific attributes
the semantics of their values follows. The NAME=VALUE attribute
value pair must come first in each cookie. The others, if present
can occur in any order. If an attribute appears more than once in
cookie, the behavior is undefined

NAME=
Required. The name of the state information ("cookie") is NAME
and its value is VALUE. NAMEs that begin with $ are reserved
other uses and must not be used by applications








Kristol & Montulli Standards Track [Page 4]

RFC 2109 HTTP State Management Mechanism February 1997


The VALUE is opaque to the user agent and may be anything
origin server chooses to send, possibly in a server-
printable ASCII encoding. "Opaque" implies that the content is
interest and relevance only to the origin server. The
may, in fact, be readable by anyone that examines the Set-
header

Comment=
Optional. Because cookies can contain private information about
user, the Cookie attribute allows an origin server to document
intended use of a cookie. The user can inspect the information
decide whether to initiate or continue a session with this cookie

Domain=
Optional. The Domain attribute specifies the domain for which
cookie is valid. An explicitly specified domain must always
with a dot

Max-Age=delta-
Optional. The Max-Age attribute defines the lifetime of
cookie, in seconds. The delta-seconds value is a decimal non
negative integer. After delta-seconds seconds elapse, the
should discard the cookie. A value of zero means the
should be discarded immediately

Path=
Optional. The Path attribute specifies the subset of URLs
which this cookie applies


Optional. The Secure attribute (with no value) directs the
agent to use only (unspecified) secure means to contact the
server whenever it sends back this cookie

The user agent (possibly under the user's control) may
what level of security it considers appropriate for "secure
cookies. The Secure attribute should be considered
advice from the server to the user agent, indicating that it is
the session's interest to protect the cookie contents

Version=
Required. The Version attribute, a decimal integer, identifies
which version of the state management specification the
conforms. For this specification, Version=1 applies







Kristol & Montulli Standards Track [Page 5]

RFC 2109 HTTP State Management Mechanism February 1997


4.2.3 Controlling

An origin server must be cognizant of the effect of possible
of both the returned resource and the Set-Cookie header.
"public" documents is desirable. For example, if the origin
wants to use a public document such as a "front door" page as
sentinel to indicate the beginning of a session for which a Set
Cookie response header must be generated, the page should be
in caches "pre-expired" so that the origin server will see
requests. "Private documents", for example those that
information strictly private to a session, should not be cached
shared caches

If the cookie is intended for use by a single user, the Set-
header should not be cached. A Set-cookie header that is intended
be shared by multiple users may be cached

The origin server should send the following additional HTTP/1.1
response headers, depending on circumstances

* To suppress caching of the Set-Cookie header: Cache-control: no
cache="set-cookie".

and one of the following

* To suppress caching of a private document in shared caches: Cache
control: private

* To allow caching of a document and require that it be
before returning it to the client: Cache-control: must-revalidate

* To allow caching of a document, but to require that proxy
(not user agent caches) validate it before returning it to
client: Cache-control: proxy-revalidate

* To allow caching of a document and request that it be
before returning it to the client (by "pre-expiring" it):
Cache-control: max-age=0. Not all caches will revalidate
document in every case

HTTP/1.1 servers must send Expires: old-date (where old-date is
date long in the past) on responses containing Set-Cookie
headers unless they know for certain (by out of band means)
there are no downsteam HTTP/1.0 proxies. HTTP/1.1 servers may
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



Kristol & Montulli Standards Track [Page 6]

RFC 2109 HTTP State Management Mechanism February 1997


4.3 User Agent

4.3.1 Interpreting Set-

The user agent keeps separate track of state information that
via Set-Cookie response headers from each origin server (
distinguished by name or IP address and port). The user
applies these defaults for optional attributes that are missing

VersionDefaults to "old cookie" behavior as originally specified
Netscape. See the HISTORICAL section

Domain Defaults to the request-host. (Note that there is no dot
the beginning of request-host.)

Max-AgeThe default behavior is to discard the cookie when the
agent exits

Path Defaults to the path of the request URL that generated
Set-Cookie response, up to, but not including,
right-most /.

Secure If absent, the user agent may send the cookie over
insecure channel

4.3.2 Rejecting

To prevent possible security or privacy violations, a user
rejects a cookie (shall not store its information) if any of
following is true

* The value for the Path attribute is not a prefix of the request
URI

* The value for the Domain attribute contains no embedded dots
does not start with a dot

* The value for the request-host does not domain-match the
attribute

* The request-host is a FQDN (not IP address) and has the form HD
where D is the value of the Domain attribute, and H is a
that contains one or more dots

Examples

* A Set-Cookie from request-host y.x.foo.com for Domain=.foo.
would be rejected, because H is y.x and contains a dot



Kristol & Montulli Standards Track [Page 7]

RFC 2109 HTTP State Management Mechanism February 1997


* A Set-Cookie from request-host x.foo.com for Domain=.foo.com
be accepted

* A Set-Cookie with Domain=.com or Domain=.com., will always
rejected, because there is no embedded dot

* A Set-Cookie with Domain=ajax.com will be rejected because
value for Domain does not begin with a dot

4.3.3 Cookie

If a user agent receives a Set-Cookie response header whose NAME
the same as a pre-existing cookie, and whose Domain and
attribute values exactly (string) match those of a pre-
cookie, the new cookie supersedes the old. However, if the Set
Cookie has a value for Max-Age of zero, the (old and new) cookie
discarded. Otherwise cookies accumulate until they expire (
permitting), at which time they are discarded

Because user agents have finite space in which to store cookies,
may also discard older cookies to make space for newer ones, using
for example, a least-recently-used algorithm, along with
on the maximum number of cookies that each origin server may set

If a Set-Cookie response header includes a Comment attribute,
user agent should store that information in a human-readable
with the cookie and should display the comment text as part of
cookie inspection user interface

User agents should allow the user to control cookie destruction.
infrequently-used cookie may function as a "preferences file"
network applications, and a user may wish to keep it even if it
the least-recently-used cookie. One possible implementation would
an interface that allows the permanent storage of a cookie through
checkbox (or, conversely, its immediate destruction).

Privacy considerations dictate that the user have
control over cookie management. The PRIVACY section contains
information

4.3.4 Sending Cookies to the Origin

When it sends a request to an origin server, the user agent sends
Cookie request header to the origin server if it has cookies that
applicable to the request, based

* the request-host




Kristol & Montulli Standards Track [Page 8]

RFC 2109 HTTP State Management Mechanism February 1997


* the request-URI

* the cookie's age

The syntax for the header is

cookie = "Cookie:" cookie-
1*((";" | ",") cookie-value
cookie-value = NAME "=" VALUE [";" path] [";" domain
cookie-version = "$Version" "="
NAME =
VALUE =
path = "$Path" "="
domain = "$Domain" "="

The value of the cookie-version attribute must be the value from
Version attribute, if any, of the corresponding Set-Cookie
header. Otherwise the value for cookie-version is 0. The value
the path attribute must be the value from the Path attribute, if any
of the corresponding Set-Cookie response header. Otherwise
attribute should be omitted from the Cookie request header.
value for the domain attribute must be the value from the
attribute, if any, of the corresponding Set-Cookie response header
Otherwise the attribute should be omitted from the Cookie
header

Note that there is no Comment attribute in the Cookie request
corresponding to the one in the Set-Cookie response header. The
agent does not return the comment information to the origin server

The following rules apply to choosing applicable cookie-values
among all the cookies the user agent has

Domain
The origin server's fully-qualified host name must domain-
the Domain attribute of the cookie

Path
The Path attribute of the cookie must match a prefix of
request-URI

Max-Age
Cookies that have expired should have been discarded and
are not forwarded to an origin server







Kristol & Montulli Standards Track [Page 9]

RFC 2109 HTTP State Management Mechanism February 1997


If multiple cookies satisfy the criteria above, they are ordered
the Cookie header such that those with more specific Path
precede those with less specific. Ordering with respect to
attributes (e.g., Domain) is unspecified

Note: For backward compatibility, the separator in the Cookie
is semi-colon (;) everywhere. A server should also accept comma (,)
as the separator between cookie-values for future compatibility

4.3.5 Sending Cookies in Unverifiable

Users must have control over sessions in order to ensure privacy
(See PRIVACY section below.) To simplify implementation and
prevent an additional layer of complexity where adequate
exist, however, this document distinguishes between transactions
are verifiable and those that are unverifiable. A transaction
verifiable if the user has the option to review the request-URI
to its use in the transaction. A transaction is unverifiable if
user does not have that option. Unverifiable transactions
arise when a user agent automatically requests inlined or
entities or when it resolves redirection (3xx) responses from
origin server. Typically the origin transaction, the
that the user initiates, is verifiable, and that transaction
directly or indirectly induce the user agent to make
transactions

When it makes an unverifiable transaction, a user agent must enable
session only if a cookie with a domain attribute D was sent
received in its origin transaction, such that the host name in
Request-URI of the unverifiable transaction domain-matches D

This restriction prevents a malicious service author from
unverifiable transactions to induce a user agent to start or
a session with a server in a different domain. The starting
continuation of such sessions could be contrary to the
expectations of the user, and could also be a security problem

User agents may offer configurable options that allow the user agent
or any autonomous programs that the user agent executes, to
the above rule, so long as these override options default to "off".

Many current user agents already provide a review option that
render many links verifiable. For instance, some user agents
the URL that would be referenced for a particular link when the
pointer is placed over that link. The user can therefore
whether to visit that site before causing the browser to do so
(Though not implemented on current user agents, a similar
could be used for a button used to submit a form -- the user



Kristol & Montulli Standards Track [Page 10]

RFC 2109 HTTP State Management Mechanism February 1997


could display the action to be taken if the user were to select
button.) However, even this would not make all links verifiable;
example, links to automatically loaded images would not normally
subject to "mouse pointer" verification

Many user agents also provide the option for a user to view the
source of a document, or to save the source to an external file
it can be viewed by another application. While such an option
provide a crude review mechanism, some users might not consider
acceptable for this purpose

4.4 How an Origin Server Interprets the Cookie

A user agent returns much of the information in the Set-Cookie
to the origin server when the Path attribute matches that of a
request. When it receives a Cookie header, the origin server
treat cookies with NAMEs whose prefix is $ specially, as an
for the adjacent cookie. The value for such a NAME is to
interpreted as applying to the lexically (left-to-right) most
cookie whose name does not have the $ prefix. If there is
previous cookie, the value applies to the cookie mechanism as
whole. For example, consider the

Cookie: $Version="1"; Customer="WILE_E_COYOTE";
$Path="/acme

$Version applies to the cookie mechanism as a whole (and gives
version number for the cookie mechanism). $Path is an
whose value (/acme) defines the Path attribute that was used when
Customer cookie was defined in a Set-Cookie response header

4.5 Caching Proxy

One reason for separating state information from both a URL
document content is to facilitate the scaling that caching permits
To support cookies, a caching proxy must obey these rules already
the HTTP specification

* Honor requests from the cache, if possible, based on cache
rules

* Pass along a Cookie request header in any request that the
must make of another server

* Return the response to the client. Include any Set-Cookie
header





Kristol & Montulli Standards Track [Page 11]

RFC 2109 HTTP State Management Mechanism February 1997


* Cache the received response subject to the control of the
headers, such as Expires, Cache-control: no-cache, and Cache
control: private

* Cache the Set-Cookie subject to the control of the usual header
Cache-control: no-cache="set-cookie". (The Set-Cookie
should usually not be cached.)

Proxies must not introduce Set-Cookie (Cookie) headers of their
in proxy responses (requests).

5.

5.1 Example 1

Most detail of request and response headers has been omitted.
the user agent has no stored cookies

1. User Agent ->

POST /acme/login HTTP/1.1
[form data

User identifies self via a form

2. Server -> User

HTTP/1.1 200
Set-Cookie: Customer="WILE_E_COYOTE"; Version="1"; Path="/acme

Cookie reflects user's identity

3. User Agent ->

POST /acme/pickitem HTTP/1.1
Cookie: $Version="1"; Customer="WILE_E_COYOTE"; $Path="/acme
[form data

User selects an item for "shopping basket."

4. Server -> User

HTTP/1.1 200
Set-Cookie: Part_Number="Rocket_Launcher_0001"; Version="1";
Path="/acme

Shopping basket contains an item




Kristol & Montulli Standards Track [Page 12]

RFC 2109 HTTP State Management Mechanism February 1997


5. User Agent ->

POST /acme/shipping HTTP/1.1
Cookie: $Version="1";
Customer="WILE_E_COYOTE"; $Path="/acme";
Part_Number="Rocket_Launcher_0001"; $Path="/acme
[form data

User selects shipping method from form

6. Server -> User

HTTP/1.1 200
Set-Cookie: Shipping="FedEx"; Version="1"; Path="/acme

New cookie reflects shipping method

7. User Agent ->

POST /acme/process HTTP/1.1
Cookie: $Version="1";
Customer="WILE_E_COYOTE"; $Path="/acme";
Part_Number="Rocket_Launcher_0001"; $Path="/acme";
Shipping="FedEx"; $Path="/acme
[form data

User chooses to process order

8. Server -> User

HTTP/1.1 200

Transaction is complete

The user agent makes a series of requests on the origin server,
each of which it receives a new cookie. All the cookies have
same Path attribute and (default) domain. Because the request
all have /acme as a prefix, and that matches the Path attribute,
request contains all the cookies received so far

5.2 Example 2

This example illustrates the effect of the Path attribute.
detail of request and response headers has been omitted. Assume
user agent has no stored cookies

Imagine the user agent has received, in response to earlier requests
the response



Kristol & Montulli Standards Track [Page 13]

RFC 2109 HTTP State Management Mechanism February 1997


Set-Cookie: Part_Number="Rocket_Launcher_0001"; Version="1";
Path="/acme



Set-Cookie: Part_Number="Riding_Rocket_0023"; Version="1";
Path="/acme/ammo

A subsequent request by the user agent to the (same) server for
of the form /acme/ammo/... would include the following
header

Cookie: $Version="1";
Part_Number="Riding_Rocket_0023"; $Path="/acme/ammo";
Part_Number="Rocket_Launcher_0001"; $Path="/acme

Note that the NAME=VALUE pair for the cookie with the more
Path attribute, /acme/ammo, comes before the one with the
specific Path attribute, /acme. Further note that the same
name appears more than once

A subsequent request by the user agent to the (same) server for a
of the form /acme/parts/ would include the following request header

Cookie: $Version="1"; Part_Number="Rocket_Launcher_0001"; $Path="/acme

Here, the second cookie's Path attribute /acme/ammo is not a
of the request URL, /acme/parts/, so the cookie does not
forwarded to the server

6. IMPLEMENTATION

Here we speculate on likely or desirable details for an origin
that implements state management

6.1 Set-Cookie

An origin server's content should probably be divided into
application areas, some of which require the use of
information. The application areas can be distinguished by
request URLs. The Set-Cookie header can incorporate
about the application areas by setting the Path attribute for
one

The session information can obviously be clear or encoded text
describes state. However, if it grows too large, it can
unwieldy. Therefore, an implementor might choose for the
information to be a key to a server-side resource. Of course,



Kristol & Montulli Standards Track [Page 14]

RFC 2109 HTTP State Management Mechanism February 1997


a database creates some problems that this state
specification was meant to avoid, namely

1. keeping real state on the server side

2. how and when to garbage-collect the database entry, in case
user agent terminates the session by, for example, exiting

6.2 Stateless

Caching benefits the scalability of WWW. Therefore it is
to reduce the number of documents that have state embedded in
inherently. For example, if a shopping-basket-style
always displays a user's current basket contents on each page,
pages cannot be cached, because each user's basket's contents
be different. On the other hand, if each page contains just a
that allows the user to "Look at My Shopping Basket", the page can
cached

6.3 Implementation

Practical user agent implementations have limits on the number
size of cookies that they can store. In general, user agents'
support should have no fixed limits. They should strive to store
many frequently-used cookies as possible. Furthermore, general-
user agents should provide each of the following minimum
individually, although not necessarily simultaneously

* at least 300

* at least 4096 bytes per cookie (as measured by the size of
characters that comprise the cookie non-terminal in the
description of the Set-Cookie header

* at least 20 cookies per unique host or domain

User agents created for specific purposes or for limited-
devices should provide at least 20 cookies of 4096 bytes, to
that the user can interact with a session-based origin server

The information in a Set-Cookie response header must be retained
its entirety. If for some reason there is inadequate space to
the cookie, it must be discarded, not truncated

Applications should use as few and as small cookies as possible,
they should cope gracefully with the loss of a cookie





Kristol & Montulli Standards Track [Page 15]

RFC 2109 HTTP State Management Mechanism February 1997


6.3.1 Denial of Service

User agents may choose to set an upper bound on the number of
to be stored from a given host or domain name or on the size of
cookie information. Otherwise a malicious server could attempt
flood a user agent with many cookies, or large cookies, on
responses, which would force out cookies the user agent had
from other servers. However, the minima specified above should
be supported

7.

7.1 User Agent

An origin server could create a Set-Cookie header to track the
of a user through the server. Users may object to this behavior
an intrusive accumulation of information, even if their identity
not evident. (Identity might become evident if a user
fills out a form that contains identifying information.) This
management specification therefore requires that a user agent
the user control over such a possible intrusion, although
interface through which the user is given this control is
unspecified. However, the control mechanisms provided shall at
allow the

* to completely disable the sending and saving of cookies

* to determine whether a stateful session is in progress

* to control the saving of a cookie on the basis of the cookie'
Domain attribute

Such control could be provided by, for example,

* to notify the user when the user agent is about to send a
to the origin server, offering the option not to begin a session

* to display a visual indication that a stateful session is
progress

* to let the user decide which cookies, if any, should be
when the user concludes a window or user agent session

* to let the user examine the contents of a cookie at any time

A user agent usually begins execution with no remembered
information. It should be possible to configure a user agent
to send Cookie headers, in which case it can never sustain state



Kristol & Montulli Standards Track [Page 16]

RFC 2109 HTTP State Management Mechanism February 1997


an origin server. (The user agent would then behave like one that
unaware of how to handle Set-Cookie response headers.)

When the user agent terminates execution, it should let the
discard all state information. Alternatively, the user agent may
the user whether state information should be retained; the
should be "no". If the user chooses to retain state information,
would be restored the next time the user agent runs

NOTE: User agents should probably be cautious about using files
store cookies long-term. If a user runs more than one instance
the user agent, the cookies could be commingled or otherwise
up

7.2 Protocol

The restrictions on the value of the Domain attribute, and the
concerning unverifiable transactions, are meant to reduce the
that cookies can "leak" to the "wrong" site. The intent is
restrict cookies to one, or a closely related set of hosts
Therefore a request-host is limited as to what values it can set
Domain. We consider it acceptable for hosts host1.foo.com
host2.foo.com to share cookies, but not a.com and b.com

Similarly, a server can only set a Path for cookies that are
to the request-URI

8. SECURITY

8.1 Clear

The information in the Set-Cookie and Cookie headers is unprotected
Two consequences are

1. Any sensitive information that is conveyed in them is
to intruders

2. A malicious intermediary could alter the headers as they
in either direction, with unpredictable results

These facts imply that information of a personal and/or
nature should only be sent over a secure channel. For less
information, or when the content of the header is a database key,
origin server should be vigilant to prevent a bad Cookie value
causing failures






Kristol & Montulli Standards Track [Page 17]

RFC 2109 HTTP State Management Mechanism February 1997


8.2 Cookie

Proper application design can avoid spoofing attacks from
domains. Consider

1. User agent makes request to victim.cracker.edu, gets
cookie session_id="1234" and sets the default
victim.cracker.edu

2. User agent makes request to spoof.cracker.edu, gets
cookie session-id="1111", with Domain=".cracker.edu".

3. User agent makes request to victim.cracker.edu again,


Cookie: $Version="1";
session_id="1234";
session_id="1111"; $Domain=".cracker.edu

The server at victim.cracker.edu should detect that the
cookie was not one it originated by noticing that the
attribute is not for itself and ignore it

8.3 Unexpected Cookie

A user agent should make every attempt to prevent the sharing
session information between hosts that are in different domains
Embedded or inlined objects may cause particularly severe
problems if they can be used to share cookies between
hosts. For example, a malicious server could embed
information for host a.com in a URI for a CGI on host b.com.
agent implementors are strongly encouraged to prevent this sort
exchange whenever possible

9. OTHER, SIMILAR,

Three other proposals have been made to accomplish similar goals
This specification is an amalgam of Kristol's State-Info proposal
Netscape's Cookie proposal

Brian Behlendorf proposed a Session-ID header that would be user
agent-initiated and could be used by an origin server to
"clicktrails". It would not carry any origin-server-defined state
however. Phillip Hallam-Baker has proposed another client-
session ID mechanism for similar purposes






Kristol & Montulli Standards Track [Page 18]

RFC 2109 HTTP State Management Mechanism February 1997


While both session IDs and cookies can provide a way to
stateful sessions, their intended purpose is different, and
consequently, the privacy requirements for them are different.
user initiates session IDs to allow servers to track progress
them, or to distinguish multiple users on a shared machine.
are server-initiated, so the cookie mechanism described here
users control over something that would otherwise take place
the users' awareness. Furthermore, cookies convey rich, server
selected information, whereas session IDs comprise user-selected
simple information

10.

10.1 Compatibility With Netscape's

HTTP/1.0 clients and servers may use Set-Cookie and Cookie
that reflect Netscape's original cookie proposal. These notes
inter-operation between "old" and "new" cookies

10.1.1 Extended Cookie

This proposal adds attribute-value pairs to the Cookie request
in a compatible way. An "old" client that receives a "new"
will ignore attributes it does not understand; it returns what
does understand to the origin server. A "new" client always
cookies in the new form

An "old" server that receives a "new" cookie will see what it
are many cookies with names that begin with a $, and it will
them. (The "old" server expects these cookies to be separated
semi-colon, not comma.) A "new" server can detect cookies that
passed through an "old" client, because they lack a $
attribute

10.1.2 Expires and Max-

Netscape's original proposal defined an Expires header that took
date value in a fixed-length variant format in place of Max-Age

Wdy, DD-Mon-YY HH:MM:SS

Note that the Expires date format contains embedded spaces, and
"old" cookies did not have quotes around values. Clients
implement to this specification should be aware of "old" cookies
Expires






Kristol & Montulli Standards Track [Page 19]

RFC 2109 HTTP State Management Mechanism February 1997


10.1.3

In Netscape's original proposal, the values in attribute-value
did not accept "-quoted strings. Origin servers should be
about sending values that require quotes unless they know
receiving user agent understands them (i.e., "new" cookies).
("new") user agent should only use quotes around values in
headers when the cookie's version(s) is (are) all compliant with
specification or later

In Netscape's original proposal, no whitespace was permitted
the = that separates attribute-value pairs. Therefore
whitespace should be used with caution in new implementations

10.2 Caching and HTTP/1.0

Some caches, such as those conforming to HTTP/1.0, will
cache the Set-Cookie header, because there was no mechanism
suppress caching of headers prior to HTTP/1.1. This caching can
to security problems. Documents transmitted by an origin
along with Set-Cookie headers will usually either be uncachable,
will be "pre-expired". As long as caches obey instructions not
cache documents (following Expires: or Pragma
no-cache (HTTP/1.0), or Cache-control: no-cache (HTTP/1.1))
uncachable documents present no problem. However, pre-
documents may be stored in caches. They require
validation (
conditional GET) on each new request, but some cache operators
the rules for their caches, and sometimes serve expired
without first validating them. This combination of factors can
to cookies meant for one user later being sent to another user.
Set-Cookie header is stored in the cache, and, although the
is stale (expired), the cache returns the document in response
later requests, including cached headers

11.

This document really represents the collective efforts of
following people, in addition to the authors: Roy Fielding,
Hedlund, Ted Hardie, Koen Holtman, Shel Kaphan, Rohit Khare












Kristol & Montulli Standards Track [Page 20]

RFC 2109 HTTP State Management Mechanism February 1997


12. AUTHORS'

David M.
Bell Laboratories, Lucent
600 Mountain Ave. Room 2A-227
Murray Hill, NJ 07974

Phone: (908) 582-2250
Fax: (908) 582-5809
EMail: dmk@bell-labs.


Lou
Netscape Communications Corp
501 E. Middlefield Rd
Mountain View, CA 94043

Phone: (415) 528-2600
EMail: montulli@netscape.
































Kristol & Montulli Standards Track [Page 21]








if you see any problems within the linking, don't worry be happy,
this is version 0.1 of the Relevance System and you gotta expect some crappy subroutines sometimes,
just be content we did not write this in Java, which would have made this "bigger and better" HAHAHHA.




RFC documents can be found at I.E.T.F.



Relevance System Copyright © 2002 Spectrum WorldResearch
other technical nosh by ServerMasters Corporation
collaboration of BobX







Spectrum