public interface Cookie
All cookies must have a name and a value and can optionally have other fields set such as path, domain, etc.
Modifier and Type | Method and Description |
---|---|
static Cookie |
cookie(String name,
String value)
Create a new cookie
|
String |
encode()
Encode the cookie to a string.
|
String |
getDomain() |
long |
getMaxAge() |
String |
getName() |
String |
getPath() |
CookieSameSite |
getSameSite() |
String |
getValue() |
boolean |
isHttpOnly() |
boolean |
isSecure() |
Cookie |
setDomain(String domain)
Sets the domain of this cookie
|
Cookie |
setHttpOnly(boolean httpOnly)
Determines if this cookie is HTTP only.
|
Cookie |
setMaxAge(long maxAge)
Sets the maximum age of this cookie in seconds.
|
Cookie |
setPath(String path)
Sets the path of this cookie.
|
Cookie |
setSameSite(CookieSameSite policy)
Sets the same site of this cookie.
|
Cookie |
setSecure(boolean secure)
Sets the security getStatus of this cookie
|
Cookie |
setValue(String value)
Sets the value of this cookie
|
static Cookie cookie(String name, String value)
name
- the name of the cookievalue
- the cookie valueString getName()
String getValue()
Cookie setValue(String value)
value
- The value to setCookie setDomain(String domain)
domain
- The domain to useString getDomain()
Cookie setPath(String path)
path
- The path to use for this cookieString getPath()
Cookie setMaxAge(long maxAge)
0
is specified, this cookie will be
automatically removed by browser because it will expire immediately.
If Long.MIN_VALUE
is specified, this cookie will be removed when the
browser is closed.
If you don't set this the cookie will be a session cookie and be removed when the browser is closed.maxAge
- The maximum age of this cookie in secondslong getMaxAge()
Cookie setSecure(boolean secure)
secure
- True if this cookie is to be secure, otherwise falseboolean isSecure()
Cookie setHttpOnly(boolean httpOnly)
httpOnly
- True if the cookie is HTTP only, otherwise false.boolean isHttpOnly()
Cookie setSameSite(CookieSameSite policy)
policy
- The policy should be one of CookieSameSite
.CookieSameSite getSameSite()
String encode()
Copyright © 2023 Eclipse. All rights reserved.