Constructor and Description |
---|
Builder(String name)
Create a cookie with no value
|
Builder(String name,
String value)
Create a cookie with name and value
|
Modifier and Type | Method and Description |
---|---|
Cookie |
build()
Build a Cookie from the specified parameters.
|
Cookie.Builder |
setComment(String comment)
Set the comment describing the purpose of this cookie.
|
Cookie.Builder |
setDomain(String domain)
Set domain attribute of the cookie.
|
Cookie.Builder |
setExpiryDate(Date date)
Set the expiration
Date of the cookie. |
Cookie.Builder |
setHttpOnly(boolean httpOnly)
Indicates that the cookie is only readable by the HTTP server and not other API's such as JavaScript.
|
Cookie.Builder |
setMaxAge(int maxAge)
Set the maximum age of the cookie, specified in seconds,
By default,
-1 indicating the cookie will persist
until browser shutdown. |
Cookie.Builder |
setPath(String path)
Set the path attribute of the cookie.
|
Cookie.Builder |
setSecured(boolean secured)
Indicates to the browser whether the cookie should only be sent using a secure protocol, such as HTTPS or SSL.
|
Cookie.Builder |
setVersion(int version)
Sets the version of the cookie protocol this cookie complies with.
|
public Builder(String name)
name
- The name of the cookiepublic Cookie.Builder setComment(String comment)
comment
- The commentpublic Cookie.Builder setExpiryDate(Date date)
Date
of the cookie.date
- The date to setpublic Cookie.Builder setDomain(String domain)
domain
- The domainpublic Cookie.Builder setPath(String path)
path
- The pathpublic Cookie.Builder setMaxAge(int maxAge)
-1
indicating the cookie will persist
until browser shutdown.public Cookie.Builder setSecured(boolean secured)
secured
- true
if securedpublic Cookie.Builder setHttpOnly(boolean httpOnly)
httpOnly
- true
if httpOnlypublic Cookie.Builder setVersion(int version)
version
- 0 if the cookie should comply with the original Netscape specification; 1 if the cookie should comply with RFC 2109public Cookie build()
Copyright © 2010–2019. All rights reserved.