public interface Cookie extends java.lang.Comparable<Cookie>, java.io.Serializable
Modifier and Type | Method and Description |
---|---|
default Cookie |
configure(CookieConfiguration configuration)
Configure the Cookie with the given configuration.
|
default Cookie |
configure(CookieConfiguration configuration,
boolean isSecure)
Configure the Cookie with the given configuration.
|
Cookie |
domain(java.lang.String domain)
Sets the domain of the cookie.
|
java.lang.String |
getDomain()
Gets the domain name of this Cookie.
|
long |
getMaxAge() |
java.lang.String |
getName() |
java.lang.String |
getPath()
The path of the cookie.
|
default java.util.Optional<SameSite> |
getSameSite()
Checks to see if this
Cookie can be sent along cross-site requests. |
java.lang.String |
getValue() |
Cookie |
httpOnly(boolean httpOnly)
Sets whether the cookie is HTTP-Only.
|
boolean |
isHttpOnly()
Checks to see if this
Cookie can only be accessed via HTTP. |
boolean |
isSecure() |
Cookie |
maxAge(long maxAge)
Sets the max age of the cookie in seconds.
|
default Cookie |
maxAge(java.time.temporal.TemporalAmount maxAge)
Sets the max age of the cookie.
|
static Cookie |
of(java.lang.String name,
java.lang.String value)
Construct a new Cookie for the given name and value.
|
Cookie |
path(java.lang.String path)
Sets the path of the cookie.
|
default Cookie |
sameSite(SameSite sameSite)
Determines if this this
Cookie can be sent along cross-site requests. |
Cookie |
secure(boolean secure)
Sets whether the cookie is secure.
|
Cookie |
value(java.lang.String value)
Sets the value.
|
@NonNull java.lang.String getName()
@NonNull java.lang.String getValue()
@Nullable java.lang.String getDomain()
Domain names are formatted according to RFC 2109.
@Nullable java.lang.String getPath()
boolean isHttpOnly()
Cookie
can only be accessed via HTTP.
If this returns true, the Cookie
cannot be accessed through client side script - But only if the
browser supports it.
See here for reference
Cookie
is HTTP-only or false if it isn'tboolean isSecure()
long getMaxAge()
default java.util.Optional<SameSite> getSameSite()
Cookie
can be sent along cross-site requests.
For more information, please look
here@NonNull default Cookie sameSite(@Nullable SameSite sameSite)
Cookie
can be sent along cross-site requests.
For more information, please look
heresameSite
- SameSite value@NonNull Cookie maxAge(long maxAge)
maxAge
- The max age@NonNull Cookie value(@NonNull java.lang.String value)
value
- The value of the cookie@NonNull Cookie domain(@Nullable java.lang.String domain)
domain
- The domain of the cookie@NonNull Cookie path(@Nullable java.lang.String path)
path
- The path of the cookie@NonNull Cookie secure(boolean secure)
secure
- Is the cookie secure@NonNull Cookie httpOnly(boolean httpOnly)
httpOnly
- Is the cookie HTTP-Only@NonNull default Cookie configure(@NonNull CookieConfiguration configuration)
configuration
- The configuration@NonNull default Cookie configure(@NonNull CookieConfiguration configuration, boolean isSecure)
configuration
- The configurationisSecure
- Is the request secure@NonNull default Cookie maxAge(@NonNull java.time.temporal.TemporalAmount maxAge)
maxAge
- The max age@NonNull static Cookie of(@NonNull java.lang.String name, @NonNull java.lang.String value)
name
- The namevalue
- The value