Interface Cookie
- All Known Subinterfaces:
SetCookie
- All Known Implementing Classes:
BasicClientCookie
public interface Cookie
Cookie interface represents a token or short packet of state information
(also referred to as "magic-cookie") that the HTTP agent and the target
server can exchange to maintain a session. In its simples form an HTTP
cookie is merely a name / value pair.
- Since:
- 4.0
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsAttribute(String name) getAttribute(String name) Deprecated.default InstantReturns creation time of the cookie.Returns domain attribute of the cookie.Deprecated.Use {getExpiryInstant()}default InstantReturns the expirationInstantof the cookie, ornullif none exists.getName()Returns the name.getPath()Returns the path attribute of the cookie.getValue()Returns the value.default booleanReturns true if this cookie has expired.booleanDeprecated.Use {isExpired(Instant)}default booleanChecks whether this Cookie has been marked ashttpOnly.booleanReturnsfalseif the cookie should be discarded at the end of the "session";trueotherwise.booleanisSecure()Indicates whether this cookie requires a secure connection.
-
Field Details
-
PATH_ATTR
- See Also:
-
DOMAIN_ATTR
- See Also:
-
MAX_AGE_ATTR
- See Also:
-
SECURE_ATTR
- See Also:
-
EXPIRES_ATTR
- See Also:
-
HTTP_ONLY_ATTR
- See Also:
-
-
Method Details
-
getAttribute
-
containsAttribute
- Since:
- 5.0
-
getName
-
getValue
-
getExpiryDate
Deprecated.Use {getExpiryInstant()}Returns the expirationDateof the cookie, ornullif none exists.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.
- Returns:
- Expiration
Date, ornull.
-
getExpiryInstant
-
isPersistent
boolean isPersistent()Returnsfalseif the cookie should be discarded at the end of the "session";trueotherwise.- Returns:
falseif the cookie should be discarded at the end of the "session";trueotherwise
-
getDomain
String getDomain()Returns domain attribute of the cookie. The value of the Domain attribute specifies the domain for which the cookie is valid.- Returns:
- the value of the domain attribute.
-
getPath
String getPath()Returns the path attribute of the cookie. The value of the Path attribute specifies the subset of URLs on the origin server to which this cookie applies.- Returns:
- The value of the path attribute.
-
isSecure
boolean isSecure()Indicates whether this cookie requires a secure connection.- Returns:
trueif this cookie should only be sent over secure connections,falseotherwise.
-
isExpired
Deprecated.Use {isExpired(Instant)}Returns true if this cookie has expired.- Parameters:
date- Current time- Returns:
trueif the cookie has expired.
-
isExpired
Returns true if this cookie has expired.- Parameters:
date- Current time- Returns:
trueif the cookie has expired.- Since:
- 5.2
-
getCreationDate
Deprecated.Returns creation time of the cookie. -
getCreationInstant
Returns creation time of the cookie. -
isHttpOnly
default boolean isHttpOnly()Checks whether this Cookie has been marked ashttpOnly.The default implementation returns
false.- Returns:
- true if this Cookie has been marked as
httpOnly, false otherwise - Since:
- 5.2
-
getCreationInstant()