Package com.teamdev.jxbrowser.cookie
Class Cookie.Builder
java.lang.Object
com.teamdev.jxbrowser.cookie.Cookie.Builder
- Enclosing interface:
- Cookie
A builder of
Cookie
.
Builders are created by invoking Cookie.newBuilder(String)
. Each of the setter methods
modifies the state of the builder and returns the same instance. Builders are not thread-safe
and should not be used concurrently from multiple threads without external synchronization.
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Returns a newCookie
built from the current state of this builder.creationTime
(Timestamp creationTime) Sets the cookie creation time.expirationTime
(Timestamp expirationTime) Sets the cookie expiration time.httpOnly
(boolean httpOnly) Specifies whether the cookie is considered HTTP only.Sets the cookie name.Sets the cookie path.Sets the SameSite cookie attribute value that allows you to declare if your cookie should be restricted to a first-party or same-site context.secure
(boolean secure) Specifies whether the cookie is restricted to a secure protocol (HTTPS or WSS) or it can be sent using any protocol.Sets the cookie value.
-
Method Details
-
name
Sets the cookie name.- Parameters:
name
- the cookie name- Returns:
- this builder
-
value
Sets the cookie value.- Parameters:
value
- the cookie value- Returns:
- this builder
-
path
Sets the cookie path. For example, "/".- Parameters:
path
- the cookie path- Returns:
- this builder
-
secure
Specifies whether the cookie is restricted to a secure protocol (HTTPS or WSS) or it can be sent using any protocol.- Parameters:
secure
- the flag value- Returns:
- this builder
-
httpOnly
Specifies whether the cookie is considered HTTP only.- Parameters:
httpOnly
- the flag value- Returns:
- this builder
-
creationTime
Sets the cookie creation time. If not specified, the current time will be assigned for the created cookie.- Parameters:
creationTime
- the cookie creation time- Returns:
- this builder
-
expirationTime
Sets the cookie expiration time. If not specified, the cookie is treated as a session cookie.- Parameters:
expirationTime
- the cookie expiration time- Returns:
- this builder
-
sameSite
Sets the SameSite cookie attribute value that allows you to declare if your cookie should be restricted to a first-party or same-site context.By default, the attribute value is set to
SameSite.LAX_MODE
which means cookies are only set when the domain in the URL of the browser matches the domain of the cookie — a first-party cookie.The
SameSite.NONE
value requires that thesecure(boolean)
attribute is set totrue
.- Parameters:
sameSite
- the SameSite cookie attribute value- Returns:
- this builder
-
build
Returns a newCookie
built from the current state of this builder.- Returns:
- a new
Cookie
instance
-