Cookie

An HttpCookie object represents an HTTP cookie, which carries state information between server and user agent. Cookie is widely adopted to create stateful sessions.

<p> There are 3 HTTP cookie specifications: <blockquote> Netscape draft<br> RFC 2109 - <a href="http://www.ietf.org/rfc/rfc2109.txt"> <i>http://www.ietf.org/rfc/rfc2109.txt</i></a><br> RFC 2965 - <a href="http://www.ietf.org/rfc/rfc2965.txt"> <i>http://www.ietf.org/rfc/rfc2965.txt</i></a> </blockquote>

<p> HttpCookie class can accept all these 3 forms of syntax.

@author Edward Wang

Constructors

this
this()
Undocumented in source.
this
this(string name, string value, int expires, string path, string domain, bool secure, bool httpOnly)

Constructs a cookie with the specified name and value.

Members

Functions

getComment
string getComment()

Returns the comment describing the purpose of this cookie, or <code>null</code> if the cookie has no comment.

getDomain
string getDomain()

Gets the domain name of this Cookie.

getMaxAge
int getMaxAge()

Gets the maximum age in seconds of this Cookie.

getName
string getName()

Returns the name of the cookie. The name cannot be changed after creation.

getPath
string getPath()

Returns the path on the server to which the browser returns this cookie. The cookie is visible to all subpaths on the server.

getSecure
bool getSecure()

Returns <code>true</code> if the browser is sending cookies only over a secure protocol, or <code>false</code> if the browser can send cookies using any protocol.

getValue
string getValue()

Gets the current value of this Cookie.

getVersion
int getVersion()

Returns the version of the protocol this cookie complies with. Version 1 complies with RFC 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.

isExpired
bool isExpired()

Reports whether this HTTP cookie has expired or not.

isHttpOnly
bool isHttpOnly()

Checks whether this Cookie has been marked as <i>HttpOnly</i>.

setComment
void setComment(string purpose)

Specifies a comment that describes a cookie's purpose. The comment is useful if the browser presents the cookie to the user. Comments are not supported by Netscape Version 0 cookies.

setDomain
void setDomain(string domain)

Specifies the domain within which this cookie should be presented.

setHttpOnly
void setHttpOnly(bool isHttpOnly)

Marks or unmarks this Cookie as <i>HttpOnly</i>.

setMaxAge
void setMaxAge(int expiry)

Sets the maximum age in seconds for this Cookie.

setName
void setName(string name)
Undocumented in source. Be warned that the author may not have intended to support it.
setPath
void setPath(string uri)

Specifies a path for the cookie to which the client should return the cookie.

setSecure
void setSecure(bool flag)

Indicates to the browser whether the cookie should only be sent using a secure protocol, such as HTTPS or SSL.

setValue
void setValue(string newValue)

Assigns a new value to this Cookie.

setVersion
void setVersion(int v)

Sets the version of the cookie protocol that this Cookie complies with.

toString
string toString()
Undocumented in source. Be warned that the author may not have intended to support it.

Meta