Class Cookie
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the comment describing the purpose of this cookie, ornullif the cookie has no comment.Returns the domain name set for this cookie.Returns the maximum age of the cookie, specified in seconds, By default,-1indicating the cookie will persist until session shutdown.getName()Returns the name of the cookie.getPath()Returns the path on the server to which the session returns this cookie.getValue()Returns the value of the cookie.Returns the version of the protocol this cookie complies with.booleanbooleanisSecure()Returnstrueif the session is sending cookies only over a secure protocol, orfalseif the session can send cookies using any protocol.setComment(String purpose) Specifies a comment that describes a cookie's purpose.Specifies the domain within which this cookie should be presented.setExpires(String expires) setHttpOnly(boolean httpOnly) setMaxAge(int expiry) Sets the maximum age of the cookie in seconds.private voidSets the cookie name and checks for validity.Specifies a path for the cookie to which the client should return the cookie.setSecure(boolean flag) Indicates to the session whether the cookie should only be sent using a secure protocol, such as HTTPS or SSL.Assigns a new value to a cookie after the cookie is created.setVersion(int version) Sets the version of the cookie protocol this cookie complies with.toString()
-
Field Details
-
name
-
value
-
comment
-
domain
-
maxAge
-
expires
-
path
-
secure
private boolean secure -
version
-
httpOnly
private boolean httpOnly
-
-
Constructor Details
-
Cookie
Creates cookie with specified name and value.The name must conform to RFC 2109. That means it can contain only ASCII alphanumeric characters and cannot contain commas, semicolons, or white space or begin with a $ character.
The value can be anything the server chooses to send.
-
Cookie
Parses cookie data from given user-agent string.
-
-
Method Details
-
setName
Sets the cookie name and checks for validity. -
getComment
Returns the comment describing the purpose of this cookie, ornullif the cookie has no comment. -
setComment
-
getDomain
Returns the domain name set for this cookie. The form of the domain name is set by RFC 2109. -
setDomain
Specifies the domain within which this cookie should be presented.The form of the domain name is specified by RFC 2109. 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 nota.b.foo.com). By default, cookies are only returned to the server that sent them. -
getMaxAge
Returns the maximum age of the cookie, specified in seconds, By default,-1indicating the cookie will persist until session shutdown. -
setMaxAge
Sets the maximum age of the cookie in seconds.A positive value indicates that the cookie will expire after that many seconds have passed. Note that the value is the maximum age when the cookie will expire, not the cookie's current age.
A negative value means that the cookie is not stored persistently and will be deleted when the Web session exits. A zero value causes the cookie to be deleted.
-
getPath
Returns the path on the server to which the session returns this cookie. The cookie is visible to all subpaths on the server. -
setPath
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 2109 (available on the Internet) for more information on setting path names for cookies.
-
isSecure
public boolean isSecure()Returnstrueif the session is sending cookies only over a secure protocol, orfalseif the session can send cookies using any protocol. -
setSecure
Indicates to the session whether the cookie should only be sent using a secure protocol, such as HTTPS or SSL. -
getName
Returns the name of the cookie. The name cannot be changed after creation. -
getValue
Returns the value of the cookie. -
setValue
-
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 session use and identify the session's cookie version. -
setVersion
Sets the version of the cookie protocol this cookie complies with. Version 0 complies with the original Netscape cookie specification. Version 1 complies with RFC 2109. -
isHttpOnly
public boolean isHttpOnly() -
setHttpOnly
-
getExpires
-
setExpires
-
toString
-