public final class
ResponseCookie
extends
HttpCookie
An
HttpCookie
subclass with the additional attributes allowed in
the "Set-Cookie" response header. To build an instance use the
from(java.lang.String)
static method.
Since:
Author:
Rossen Stoyanchev, Brian Clozel
See Also:
RFC 6265
Factory method to obtain a builder for a server-defined cookie, given its
name only, and where the value as well as other attributes can be set
later via builder methods.
Factory method to obtain a builder for a server-defined cookie that starts
with a name-value pair and may also include attributes.
Factory method to obtain a builder for a server-defined cookie.
Return the cookie "Domain" attribute, or
null
if not set.
Return the cookie "Max-Age" attribute in seconds.
Return the cookie "Path" attribute, or
null
if not set.
Return the cookie "SameSite" attribute, or
null
if not set.
boolean
Return
true
if the cookie has the "HttpOnly" attribute.
boolean
Return
true
if the cookie has the "Secure" attribute.
Return a builder pre-populated with values from
"this"
instance.
getMaxAge
Return the cookie "Max-Age" attribute in seconds.
A positive value indicates when the cookie expires relative to the
current time. A value of 0 means the cookie should expire immediately.
A negative value means no "Max-Age" attribute in which case the cookie
is removed when the browser is closed.
isHttpOnly
public
boolean
isHttpOnly
()
Return
true
if the cookie has the "HttpOnly" attribute.
See Also:
https://www.owasp.org/index.php/HTTPOnly
Return the cookie "SameSite" attribute, or
null
if not set.
This limits the scope of the cookie such that it will only be attached to
same site requests if
"Strict"
or cross-site requests if
"Lax"
.
Since:
See Also:
RFC6265 bis
mutate
Return a builder pre-populated with values from
"this"
instance.
Since:
Factory method to obtain a builder for a server-defined cookie, given its
name only, and where the value as well as other attributes can be set
later via builder methods.
Parameters:
name
- the cookie name
Returns:
a builder to create the cookie with
Since:
Factory method to obtain a builder for a server-defined cookie that starts
with a name-value pair and may also include attributes.
Parameters:
name
- the cookie name
value
- the cookie value
Returns:
a builder to create the cookie with
fromClientResponse
Factory method to obtain a builder for a server-defined cookie. Unlike
from(String, String)
this option assumes input from a remote
server, which can be handled more leniently, e.g. ignoring an empty domain
name with double quotes.
Parameters:
name
- the cookie name
value
- the cookie value
Returns:
a builder to create the cookie with
Since:
5.2.5