public class Cookie extends Object implements NameAndValue
Cookie cookie = new Cookie.Builder("name", "value").setComment("some comment").setExpiryDate(someDate).build();Credits: Some of the javadoc in this class is copied from the
org.apache.http.cookie.Cookie
class in Apache HTTP Client.
and some (version and secured) from Scalatra.Modifier and Type | Class and Description |
---|---|
static class |
Cookie.Builder |
Modifier and Type | Field and Description |
---|---|
static String |
COMMENT |
static String |
DOMAIN |
static String |
EXPIRES |
static String |
HTTP_ONLY |
static String |
MAX_AGE |
static String |
PATH |
static String |
SAME_SITE |
static String |
SECURE |
static String |
VERSION |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
String |
getComment()
Returns the comment describing the purpose of this cookie, or
null if no such comment has been defined.
|
String |
getDomain()
Returns domain attribute of the cookie.
|
Date |
getExpiryDate()
Returns the expiration
Date of the cookie, or null
if none exists. |
int |
getMaxAge()
Returns the maximum age of the cookie, specified in seconds,
By default,
-1 indicating the cookie will persist
until browser shutdown. |
String |
getName()
Returns the name.
|
String |
getPath()
Returns the path attribute of the cookie.
|
String |
getSameSite()
Returns the SameSite attribute of the cookie.
|
String |
getValue()
Returns the value.
|
int |
getVersion()
Gets the version of the cookie protocol this cookie complies with.
|
boolean |
hasComment() |
boolean |
hasDomain() |
boolean |
hasExpiryDate() |
int |
hashCode() |
boolean |
hasMaxAge() |
boolean |
hasPath() |
boolean |
hasSameSite() |
boolean |
hasValue() |
boolean |
hasVersion() |
boolean |
isHttpOnly()
Indicates that the cookie is only readable by the HTTP server and not other API's such as JavaScript.
|
boolean |
isSecured()
Indicates to the browser whether the cookie should only be sent using a secure protocol, such as HTTPS or SSL.
|
String |
toString() |
public static final String COMMENT
public static final String PATH
public static final String DOMAIN
public static final String MAX_AGE
public static final String SECURE
public static final String HTTP_ONLY
public static final String EXPIRES
public static final String VERSION
public static final String SAME_SITE
public String getName()
getName
in interface NameAndValue
public String getValue()
getValue
in interface NameAndValue
public boolean hasValue()
true
if this cookie has a value defined, false
otherwise.public String getComment()
public boolean hasComment()
true
if this cookie has a comment defined, false
otherwise.public Date getExpiryDate()
Date
of the cookie, or null
if none exists.Date
, or null.public boolean hasExpiryDate()
true
if this cookie has an expiry defined, false
otherwise.public String getDomain()
public boolean hasDomain()
true
if this cookie has a domain defined, false
otherwise.public String getPath()
public boolean hasPath()
true
if this cookie has a path defined, false
otherwise.public boolean isSecured()
true
if this cookies is secured.public boolean isHttpOnly()
true
if httpOnlypublic int getVersion()
public boolean hasVersion()
true
if this cookie has a version defined, false
otherwise.public int getMaxAge()
-1
indicating the cookie will persist
until browser shutdown.public boolean hasMaxAge()
true
if this cookie has a Max-Age defined, false
otherwise.public String getSameSite()
public boolean hasSameSite()
true
if this cookie has a SameSite attribute defined, false
otherwise.Copyright © 2010–2020. All rights reserved.