Fluent builder for a single cookie, obtained from HttpWrapper.cookieBuilder(name). Each setter returns the same builder so calls can be chained, and build() adds the finished cookie to the current response. The cookie's SameSite attribute defaults to Strict.
Group: Builders
Methods
value(String value)
Returns: CookieBuilder
Sets the cookie's value.
| Parameter | Description |
|---|---|
value | the value to record on the cookie |
secure(boolean secure)
Returns: CookieBuilder
Sets whether the cookie is only sent over HTTPS connections.
| Parameter | Description |
|---|---|
secure | true to mark the cookie secure, false otherwise |
expiry(int expiry)
Returns: CookieBuilder
Sets how long, in seconds, the cookie remains valid for.
| Parameter | Description |
|---|---|
expiry | the number of seconds the cookie will remain valid for |
path(String path)
Returns: CookieBuilder
Sets the URL path scope the cookie applies to.
| Parameter | Description |
|---|---|
path | the URL path scope for the cookie |
httpOnly(boolean httpOnly)
Returns: CookieBuilder
Sets whether the cookie is hidden from client-side script access.
| Parameter | Description |
|---|---|
httpOnly | true to mark the cookie HttpOnly, false otherwise |
sameSite(String ss)
Returns: CookieBuilder
Sets the cookie's SameSite attribute, overriding the Strict default.
| Parameter | Description |
|---|---|
ss | the SameSite value - None, Lax or Strict |
build()
Returns: Cookie
Builds the cookie and adds it to the current HTTP response.