Top Description Fields Methods
org.apache.hc.client5.http.cookie

public Interface Cookie

Known Direct Subinterfaces
org.apache.hc.client5.http.cookie.SetCookie
Imports
java.time.Instant, java.util.Date

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

Modifier and TypeField and Description
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String

Method Summary

Modifier and TypeMethod and Description
public boolean
public String
public Date
getCreationDate()

Deprecated Use getCreationInstant()
Returns creation time of the cookie.
public default Instant
getCreationInstant()

Returns creation time of the cookie.

public String

Returns:

the value of the domain attribute.
getDomain
()

Returns domain attribute of the cookie.

public Date

Returns:

Expiration Date, or null.
getExpiryDate
()

Deprecated Use {getExpiryInstant()}
Returns the expiration Date of the cookie, or null if none exists.
public default Instant

Returns:

Expiration Instant, or null.
getExpiryInstant
()

Returns the expiration Instant of the cookie, or null if none exists.

public String

Returns:

String name The name
getName
()

Returns the name.

public String

Returns:

The value of the path attribute.
getPath
()

Returns the path attribute of the cookie.

public String

Returns:

String value The current value.
getValue
()

Returns the value.

public boolean

Returns:

true if the cookie has expired.
isExpired
(final Date
Current time
date
)

Deprecated Use {isExpired(Instant)}
Returns true if this cookie has expired.
public default boolean

Returns:

true if the cookie has expired.
isExpired
(final Instant
Current time
date
)

Returns true if this cookie has expired.

public default boolean

Returns:

true if this Cookie has been marked as httpOnly, false otherwise
isHttpOnly
()

Checks whether this Cookie has been marked as httpOnly.

public boolean

Returns:

false if the cookie should be discarded at the end of the "session"; true otherwise
isPersistent
()

Returns false if the cookie should be discarded at the end of the "session"; true otherwise.

public boolean

Returns:

true if this cookie should only be sent over secure connections, false otherwise.
isSecure
()

Indicates whether this cookie requires a secure connection.

Field Detail

DOMAIN_ATTRback to summary
public static final String DOMAIN_ATTR
EXPIRES_ATTRback to summary
public static final String EXPIRES_ATTR
HTTP_ONLY_ATTRback to summary
public static final String HTTP_ONLY_ATTR
MAX_AGE_ATTRback to summary
public static final String MAX_AGE_ATTR
PATH_ATTRback to summary
public static final String PATH_ATTR
SECURE_ATTRback to summary
public static final String SECURE_ATTR

Method Detail

containsAttributeback to summary
public boolean containsAttribute(String name)
Since
5.0
getAttributeback to summary
public String getAttribute(String name)
Since
5.0
getCreationDateback to summary
public Date getCreationDate()

Deprecated

Use getCreationInstant()

Returns creation time of the cookie.

Annotations
@Deprecated
getCreationInstantback to summary
public default Instant getCreationInstant()

Returns creation time of the cookie.

getDomainback to summary
public String getDomain()

Returns domain attribute of the cookie. The value of the Domain attribute specifies the domain for which the cookie is valid.

Returns:String

the value of the domain attribute.

getExpiryDateback to summary
public Date getExpiryDate()

Deprecated

Use {getExpiryInstant()}

Returns the expiration Date of the cookie, or null if 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:Date

Expiration Date, or null.

Annotations
@Deprecated
getExpiryInstantback to summary
public default Instant getExpiryInstant()

Returns the expiration Instant of the cookie, or null if 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:Instant

Expiration Instant, or null.

Annotations
@SuppressWarnings:deprecated
Since
5.2
getNameback to summary
public String getName()

Returns the name.

Returns:String

String name The name

getPathback to summary
public 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:String

The value of the path attribute.

getValueback to summary
public String getValue()

Returns the value.

Returns:String

String value The current value.

isExpiredback to summary
public boolean isExpired(final Date date)

Deprecated

Use {isExpired(Instant)}

Returns true if this cookie has expired.

Parameters
date:Date

Current time

Returns:boolean

true if the cookie has expired.

Annotations
@Deprecated
isExpiredback to summary
public default boolean isExpired(final Instant date)

Returns true if this cookie has expired.

Parameters
date:Instant

Current time

Returns:boolean

true if the cookie has expired.

Annotations
@SuppressWarnings:deprecation
Since
5.2
isHttpOnlyback to summary
public default boolean isHttpOnly()

Checks whether this Cookie has been marked as httpOnly.

The default implementation returns false.

Returns:boolean

true if this Cookie has been marked as httpOnly, false otherwise

Since
5.2
isPersistentback to summary
public boolean isPersistent()

Returns false if the cookie should be discarded at the end of the "session"; true otherwise.

Returns:boolean

false if the cookie should be discarded at the end of the "session"; true otherwise

isSecureback to summary
public boolean isSecure()

Indicates whether this cookie requires a secure connection.

Returns:boolean

true if this cookie should only be sent over secure connections, false otherwise.