public static class H.Cookie extends Object implements Serializable
The HTTP cookie
| Modifier and Type | Class and Description |
|---|---|
static class |
H.Cookie.F
The function object namespace
|
| Constructor and Description |
|---|
Cookie(String name) |
Cookie(String name,
String value) |
Cookie(String name,
String value,
int maxAge,
boolean secure,
String path,
String domain,
boolean httpOnly) |
Cookie(String name,
String value,
String path) |
| Modifier and Type | Method and Description |
|---|---|
H.Cookie |
addToResponse() |
String |
comment() |
H.Cookie |
comment(String comment) |
H.Cookie |
decr() |
H.Cookie |
decr(int n) |
String |
domain()
Returns the domain of the cookie
|
H.Cookie |
domain(String domain)
Set the domain of the cookie
|
Date |
expires() |
H.Cookie |
expires(Date expires) |
boolean |
httpOnly() |
H.Cookie |
httpOnly(boolean httpOnly) |
H.Cookie |
incr() |
H.Cookie |
incr(int n) |
int |
maxAge()
Returns the maximum age of cookie specified in seconds.
|
H.Cookie |
maxAge(int maxAge)
Set the max age of the cookie in seconds.
|
String |
name()
Returns the name of the cookie.
|
String |
path()
Returns the path on the server to which the browser returns this cookie.
|
H.Cookie |
path(String uri)
Specifies a path for the cookie to which the client should return the cookie.
|
boolean |
secure()
Returns
true if the browser is sending cookies only over a secure protocol, or false if the browser can send cookies using any protocol. |
H.Cookie |
secure(boolean secure)
Indicates to the browser whether the cookie should only be sent using a secure protocol, such as HTTPS or SSL.
|
String |
value()
Returns the value of the cookie
|
H.Cookie |
value(String value)
Set a value to a cookie and the return
this cookie |
int |
version()
Returns the version of the protocol this cookie complies with.
|
H.Cookie |
version(int v)
Sets the version of the cookie protocol that this Cookie complies with.
|
public Cookie(String name)
public String name()
Returns the name of the cookie. Cookie name cannot be changed after created
public String value()
Returns the value of the cookie
public H.Cookie value(String value)
Set a value to a cookie and the return this cookie
value - the value to be set to the cookiepublic String domain()
Returns the domain of the cookie
public H.Cookie domain(String domain)
Set the domain of the cookie
domain - the domain stringpublic String path()
Returns the path on the server to which the browser returns this cookie. The cookie is visible to all subpaths on the server.
path(String)public H.Cookie path(String uri)
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.
Consult RFC 2109 (available on the Internet) for more information on setting path names for cookies.
uri - a String specifying a pathpathpublic int maxAge()
Returns the maximum age of cookie specified in seconds. If maxAge is set to -1 then the cookie will persist until browser shutdown
public H.Cookie maxAge(int maxAge)
Set the max 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 browser exits. A zero value causes the cookie to be deleted.
maxAge - the max age to be setmaxAge()public Date expires()
public boolean secure()
Returns true if the browser is sending cookies only over a secure protocol, or false if the browser can send cookies using any protocol.
secure(boolean)public H.Cookie secure(boolean secure)
Indicates to the browser whether the cookie should only be sent using a secure protocol, such as HTTPS or SSL.
The default value is false.
secure - the cookie secure requirementpublic int version()
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.
version(int)public H.Cookie version(int v)
Sets the version of the cookie protocol that this Cookie complies with.
Version 0 complies with the original Netscape cookie specification. Version 1 complies with RFC 2109.
Since RFC 2109 is still somewhat new, consider version 1 as experimental; do not use it yet on production sites.
v - 0 if the cookie should comply with the original Netscape specification; 1 if the cookie should comply with RFC 2109version()public boolean httpOnly()
public H.Cookie httpOnly(boolean httpOnly)
public String comment()
public H.Cookie decr()
public H.Cookie decr(int n)
public H.Cookie incr()
public H.Cookie incr(int n)
public H.Cookie addToResponse()
Copyright © 2017–2018 OSGL (Open Source General Library). All rights reserved.