T
- the current AbstractNewCookieBuilder type.public abstract static class NewCookie.AbstractNewCookieBuilder<T extends NewCookie.AbstractNewCookieBuilder<T>> extends Cookie.AbstractCookieBuilder<NewCookie.AbstractNewCookieBuilder<T>>
NewCookie
builder class.Constructor and Description |
---|
AbstractNewCookieBuilder(Cookie cookie)
Create a new instance supplementing the information in the supplied cookie.
|
AbstractNewCookieBuilder(java.lang.String name)
Create a new instance.
|
Modifier and Type | Method and Description |
---|---|
abstract NewCookie |
build()
Build a new
NewCookie instance using all the configuration previously specified in this builder. |
T |
comment(java.lang.String comment)
Set the comment associated with the cookie.
|
T |
expiry(java.util.Date expiry)
Set the cookie expiry date.
|
T |
httpOnly(boolean httpOnly)
Whether the cookie will only be visible as part of an HTTP request.
|
T |
maxAge(int maxAge)
Set the maximum age of the the cookie in seconds.
|
T |
sameSite(NewCookie.SameSite sameSite)
Set the attribute that controls whether the cookie is sent with cross-origin requests, providing protection against
cross-site request forgery.
|
T |
secure(boolean secure)
Whether the cookie will only be sent over a secure connection.
|
domain, path, value, version
public AbstractNewCookieBuilder(java.lang.String name)
name
- the name of the cookie.public AbstractNewCookieBuilder(Cookie cookie)
cookie
- the cookie to clone.public T comment(java.lang.String comment)
comment
- the comment.public T maxAge(int maxAge)
-1
indicates that the cookie will be discarded at the end of the
browser/application session.maxAge
- the maximum age in seconds.expiry(Date)
public T expiry(java.util.Date expiry)
Note that it is recommended to use Max-Age
to control cookie expiration, however some browsers
do not understand Max-Age
, in which case setting Expires
parameter may be necessary.
expiry
- the cookie expiry datemaxAge(int)
public T secure(boolean secure)
false
.secure
- specifies whether the cookie will only be sent over a secure connection.public T httpOnly(boolean httpOnly)
false
.httpOnly
- if true
make the cookie HTTP only, i.e. only visible as part of an HTTP request.public T sameSite(NewCookie.SameSite sameSite)
sameSite
- specifies the value of the SameSite
cookie attribute.public abstract NewCookie build()
NewCookie
instance using all the configuration previously specified in this builder.build
in class Cookie.AbstractCookieBuilder<NewCookie.AbstractNewCookieBuilder<T extends NewCookie.AbstractNewCookieBuilder<T>>>
NewCookie
instance.java.lang.IllegalArgumentException
- if name is null
.