Interface SetCookie
- All Superinterfaces:
Cookie
- All Known Implementing Classes:
BasicClientCookie
This interface represents a
Set-Cookie response header sent by the
origin server to the HTTP agent in order to maintain a conversational state.- Since:
- 4.0
-
Field Summary
Fields inherited from interface Cookie
DOMAIN_ATTR, EXPIRES_ATTR, HTTP_ONLY_ATTR, MAX_AGE_ATTR, PATH_ATTR, SECURE_ATTR -
Method Summary
Modifier and TypeMethodDescriptionvoidSets the domain attribute.default voidsetExpiryDate(Instant expiryDate) Sets expiration date.voidsetExpiryDate(Date expiryDate) Deprecated.default voidsetHttpOnly(boolean httpOnly) Marks or unmarks this Cookie ashttpOnly.voidSets the path attribute.voidsetSecure(boolean secure) Sets the secure attribute of the cookie.voidMethods inherited from interface Cookie
containsAttribute, getAttribute, getCreationDate, getCreationInstant, getDomain, getExpiryDate, getExpiryInstant, getName, getPath, getValue, isExpired, isExpired, isHttpOnly, isPersistent, isSecure
-
Method Details
-
setValue
-
setExpiryDate
Deprecated.Use {setExpiryDate(Instant)}Sets expiration date.Note: the object returned by this method is considered immutable. Changing it (e.g. using setTime()) could result in undefined behaviour. Do so at your peril.
- Parameters:
expiryDate- theDateafter which this cookie is no longer valid.- See Also:
-
setExpiryDate
Sets expiration date.Note: the object returned by this method is considered immutable. Changing it (e.g. using setTime()) could result in undefined behaviour. Do so at your peril.
- Parameters:
expiryDate- theInstantafter which this cookie is no longer valid.- Since:
- 5.2
- See Also:
-
setDomain
Sets the domain attribute.- Parameters:
domain- The value of the domain attribute- See Also:
-
setPath
Sets the path attribute.- Parameters:
path- The value of the path attribute- See Also:
-
setSecure
void setSecure(boolean secure) Sets the secure attribute of the cookie.When
truethe cookie should only be sent using a secure protocol (https). This should only be set when the cookie's originating server used a secure protocol to set the cookie's value.- Parameters:
secure- The value of the secure attribute- See Also:
-
setHttpOnly
default void setHttpOnly(boolean httpOnly) Marks or unmarks this Cookie ashttpOnly.- Parameters:
httpOnly- true if this cookie is to be marked ashttpOnly, false otherwise- Since:
- 5.2
-
setExpiryDate(Instant)}