public class Cookie extends Object
Context.setResponseCookie(Cookie)
.Constructor and Description |
---|
Cookie(String name)
Creates a response cookie without a value.
|
Cookie(String name,
String value)
Creates a response cookie.
|
Modifier and Type | Method and Description |
---|---|
Cookie |
clone()
Copy all state from this cookie and creates a new cookie.
|
String |
getDomain()
Cookie's domain.
|
String |
getDomain(String domain)
Get cookie's domain.
|
long |
getMaxAge()
Max age value:
-
-1 : indicates a browser session. |
String |
getName()
Cookie's name.
|
String |
getPath()
Cookie's path.
|
String |
getPath(String path)
Cookie's path.
|
String |
getValue()
Cookie's value.
|
boolean |
isHttpOnly()
Cookie's http-only flag.
|
boolean |
isSecure()
Secure cookie.
|
Cookie |
setDomain(String domain)
Set cookie's domain.
|
Cookie |
setHttpOnly(boolean httpOnly)
Set cookie's http-only.
|
Cookie |
setMaxAge(Duration maxAge)
Set max age value:
-
-1 : indicates a browser session. |
Cookie |
setMaxAge(long maxAge)
Set max age value:
-
-1 : indicates a browser session. |
Cookie |
setName(String name)
Set cookie's name.
|
Cookie |
setPath(String path)
Set cookie's path.
|
Cookie |
setSecure(boolean secure)
Set cookie secure flag..
|
Cookie |
setValue(String value)
Set cookie's value.
|
String |
toCookieString()
Generates a cookie string.
|
String |
toString() |
public Cookie(@Nonnull String name, @Nullable String value)
name
- Cookie's name.value
- Cookie's value or null
.@Nonnull public Cookie setName(@Nonnull String name)
name
- Cookie's name.@Nonnull public Cookie setValue(@Nonnull String value)
value
- Cookie's value.@Nonnull public String getDomain(@Nonnull String domain)
domain
- Defaults cookie's domain.@Nonnull public Cookie setDomain(@Nonnull String domain)
domain
- Cookie's domain.@Nonnull public String getPath(@Nonnull String path)
path
- Defaults path.@Nonnull public Cookie setPath(@Nonnull String path)
path
- Cookie's path.public boolean isHttpOnly()
public Cookie setHttpOnly(boolean httpOnly)
httpOnly
- Cookie's http-only.public boolean isSecure()
@Nonnull public Cookie setSecure(boolean secure)
secure
- Cookie's secure.public long getMaxAge()
-1
: indicates a browser session. It is deleted when user closed the browser.
- 0
: indicates a cookie has expired and browser must delete the cookie.
- positive value
: indicates the number of seconds from current date, where browser
must expires the cookie.@Nonnull public Cookie setMaxAge(@Nonnull Duration maxAge)
-1
: indicates a browser session. It is deleted when user closed the browser.
- 0
: indicates a cookie has expired and browser must delete the cookie.
- positive value
: indicates the number of seconds from current date, where browser
must expires the cookie.maxAge
- Cookie max age.@Nonnull public Cookie setMaxAge(long maxAge)
-1
: indicates a browser session. It is deleted when user closed the browser.
- 0
: indicates a cookie has expired and browser must delete the cookie.
- positive value
: indicates the number of seconds from current date, where browser
must expires the cookie.maxAge
- Cookie max age, in seconds.Copyright © 2019. All rights reserved.