public final class HttpCookie extends Object implements Cloneable
There are 3 HTTP cookie specifications:
Netscape draft
RFC 2109 - http://www.ietf.org/rfc/rfc2109.txt
RFC 2965 - http://www.ietf.org/rfc/rfc2965.txt
HttpCookie class can accept all these 3 forms of syntax.
Constructor | Description |
---|---|
HttpCookie(String name,
String value) |
Constructs a cookie with a specified name and value.
|
Modifier and Type | Method | Description |
---|---|---|
Object |
clone() |
Create and return a copy of this object.
|
static boolean |
domainMatches(String domain,
String host) |
The utility method to check whether a host name is in a domain or not.
|
boolean |
equals(Object obj) |
Test the equality of two HTTP cookies.
|
String |
getComment() |
Returns the comment describing the purpose of this cookie, or
null if the cookie has no comment. |
String |
getCommentURL() |
Returns the comment URL describing the purpose of this cookie, or
null if the cookie has no comment URL. |
boolean |
getDiscard() |
Returns the discard attribute of the cookie
|
String |
getDomain() |
Returns the domain name set for this cookie.
|
long |
getMaxAge() |
Returns the maximum age of the cookie, specified in seconds.
|
String |
getName() |
Returns the name of the cookie.
|
String |
getPath() |
Returns the path on the server to which the browser returns this cookie.
|
String |
getPortlist() |
Returns the port list attribute of the cookie
|
boolean |
getSecure() |
Returns
true if sending this cookie should be restricted to a
secure protocol, or false if the it can be sent using any
protocol. |
String |
getValue() |
Returns the value of the cookie.
|
int |
getVersion() |
Returns the version of the protocol this cookie complies with.
|
boolean |
hasExpired() |
Reports whether this HTTP cookie has expired or not.
|
int |
hashCode() |
Returns the hash code of this HTTP cookie.
|
boolean |
isHttpOnly() |
Returns
true if this cookie contains the HttpOnly
attribute. |
static List<HttpCookie> |
parse(String header) |
Constructs cookies from set-cookie or set-cookie2 header string.
|
void |
setComment(String purpose) |
Specifies a comment that describes a cookie's purpose.
|
void |
setCommentURL(String purpose) |
Specifies a comment URL that describes a cookie's purpose.
|
void |
setDiscard(boolean discard) |
Specify whether user agent should discard the cookie unconditionally.
|
void |
setDomain(String pattern) |
Specifies the domain within which this cookie should be presented.
|
void |
setHttpOnly(boolean httpOnly) |
Indicates whether the cookie should be considered HTTP Only.
|
void |
setMaxAge(long expiry) |
Sets the maximum age of the cookie in seconds.
|
void |
setPath(String uri) |
Specifies a path for the cookie to which the client should return
the cookie.
|
void |
setPortlist(String ports) |
Specify the portlist of the cookie, which restricts the port(s)
to which a cookie may be sent back in a Cookie header.
|
void |
setSecure(boolean flag) |
Indicates whether the cookie should only be sent using a secure protocol,
such as HTTPS or SSL.
|
void |
setValue(String newValue) |
Assigns a new value to a cookie after the cookie is created.
|
void |
setVersion(int v) |
Sets the version of the cookie protocol this cookie complies
with.
|
String |
toString() |
Constructs a cookie header string representation of this cookie,
which is in the format defined by corresponding cookie specification,
but without the leading "Cookie:" token.
|