Constructs a cookie with a specified name and value.
The name must conform to RFC 2965. That means it can contain
only ASCII alphanumeric characters and cannot contain commas,
semicolons, or white space or begin with a $ character. The cookie's
name cannot be changed after creation.
The value can be anything the server chooses to send. Its
value is probably of interest only to the server. The cookie's
value can be changed after creation with the
By default, cookies are created according to the RFC 2965
cookie specification. The version can be changed with the
name - a String specifying the name of the cookie
value - a String specifying the value of the cookie
IllegalArgumentException - if the cookie name contains illegal characters
or it is one of the tokens reserved for use
by the cookie protocol
Constructs cookies from set-cookie or set-cookie2 header string.
RFC 2965 section 3.2.2 set-cookie2 syntax indicates that one header line
may contain more than one cookie definitions, so this is a static
utility method instead of another constructor.
header - a String specifying the set-cookie header.
The header should start with "set-cookie", or "set-cookie2"
token; or it should have no leading token at all.
a List of cookie parsed from header line string
IllegalArgumentException - if header string violates the cookie
specification's syntax, or the cookie
name contains llegal characters, or
the cookie name is one of the tokens
reserved for use by the cookie protocol
Specifies the domain within which this cookie should be presented.
The form of the domain name is specified by RFC 2965. A domain
name begins with a dot (.foo.com) and means that
the cookie is visible to servers in a specified Domain Name System
(DNS) zone (for example, www.foo.com, but not
a.b.foo.com). By default, cookies are only returned
to the server that sent them.
pattern - a String containing the domain name
within which this cookie is visible;
form is according to RFC 2965
Specifies a path for the cookie
to which the client should return the cookie.
The cookie is visible to all the pages in the directory
you specify, and all the pages in that directory's subdirectories.
A cookie's path must include the servlet that set the cookie,
for example, /catalog, which makes the cookie
visible to all directories on the server under /catalog.
Consult RFC 2965 (available on the Internet) for more
information on setting path names for cookies.
Assigns a new value to a cookie after the cookie is created.
If you use a binary value, you may want to use BASE64 encoding.
With Version 0 cookies, values should not contain white
space, brackets, parentheses, equals signs, commas,
double quotes, slashes, question marks, at signs, colons,
and semicolons. Empty values may not behave the same way
on all browsers.
Returns the version of the protocol this cookie complies
with. Version 1 complies with RFC 2965/2109,
and version 0 complies with the original
cookie specification drafted by Netscape. Cookies provided
by a browser use and identify the browser's cookie version.
0 if the cookie complies with the
original Netscape specification; 1
if the cookie complies with RFC 2965/2109
Return hash code of this http cookie. The result is the sum of
hash code value of three significant components of this cookie:
name, domain, and path.
That is, the hash code is the value of the expression:
Submit a bug or feature For further API reference and developer documentation, see Java SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.