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

public Interface SetCookie

extends Cookie
Known Direct Implementers
org.apache.hc.client5.http.impl.cookie.BasicClientCookie
Imports
java.time.Instant, java.util.Date, org.apache.hc.client5.http.utils.DateUtils

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

Inherited from org.apache.hc.client5.http.cookie.Cookie:
DOMAIN_ATTREXPIRES_ATTRHTTP_ONLY_ATTRMAX_AGE_ATTRPATH_ATTRSECURE_ATTR

Method Summary

Modifier and TypeMethod and Description
public void
setDomain(String
The value of the domain attribute
domain
)

Sets the domain attribute.

public void
setExpiryDate(Date
the Date after which this cookie is no longer valid.
expiryDate
)

Deprecated Use {setExpiryDate(Instant)}
Sets expiration date.
public default void
setExpiryDate(Instant
the Instant after which this cookie is no longer valid.
expiryDate
)

Sets expiration date.

public default void
setHttpOnly(final boolean
true if this cookie is to be marked as httpOnly, false otherwise
httpOnly
)

Marks or unmarks this Cookie as httpOnly.

public void
setPath(String
The value of the path attribute
path
)

Sets the path attribute.

public void
setSecure(boolean
The value of the secure attribute
secure
)

Sets the secure attribute of the cookie.

public void
Inherited from org.apache.hc.client5.http.cookie.Cookie:
containsAttributegetAttributegetCreationDategetCreationInstantgetDomaingetExpiryDategetExpiryInstantgetNamegetPathgetValueisExpiredisExpiredisHttpOnlyisPersistentisSecure

Method Detail

setDomainback to summary
public void setDomain(String domain)

Sets the domain attribute.

Parameters
domain:String

The value of the domain attribute

See Also
Cookie#getDomain
setExpiryDateback to summary
public void setExpiryDate(Date expiryDate)

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:Date

the Date after which this cookie is no longer valid.

Annotations
@Deprecated
See Also
Cookie#getExpiryDate
setExpiryDateback to summary
public default void setExpiryDate(Instant expiryDate)

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:Instant

the Instant after which this cookie is no longer valid.

Annotations
@SuppressWarnings:deprecated
Since
5.2
See Also
Cookie#getExpiryInstant()
setHttpOnlyback to summary
public default void setHttpOnly(final boolean httpOnly)

Marks or unmarks this Cookie as httpOnly.

Parameters
httpOnly:boolean

true if this cookie is to be marked as httpOnly, false otherwise

Since
5.2
setPathback to summary
public void setPath(String path)

Sets the path attribute.

Parameters
path:String

The value of the path attribute

See Also
Cookie#getPath
setSecureback to summary
public void setSecure(boolean secure)

Sets the secure attribute of the cookie.

When true the 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:boolean

The value of the secure attribute

See Also
isSecure()
setValueback to summary
public void setValue(String value)