Package io.javalin.http
Class Cookie
-
- All Implemented Interfaces:
public final class Cookie
An HTTP cookie (web cookie, browser cookie) is a small piece of data that a server sends to a user's web browser. The browser may store the cookie and send it back to the same server with later requests. Typically, an HTTP cookie is used to tell if two requests come from the same browser.
-
-
Constructor Summary
Constructors Constructor Description Cookie(String name, String value, String path, Integer maxAge, Boolean secure, Integer version, Boolean isHttpOnly, String comment, String domain, SameSite sameSite)
Cookie(String name, String value, String path, Integer maxAge, Boolean secure, Integer version, Boolean isHttpOnly, String comment, String domain)
Cookie(String name, String value, String path, Integer maxAge, Boolean secure, Integer version, Boolean isHttpOnly, String comment)
Cookie(String name, String value, String path, Integer maxAge, Boolean secure, Integer version, Boolean isHttpOnly)
Cookie(String name, String value, String path, Integer maxAge, Boolean secure, Integer version)
Cookie(String name, String value, String path, Integer maxAge, Boolean secure)
Cookie(String name, String value, String path, Integer maxAge)
Cookie(String name, String value, String path)
Cookie(String name, String value)
-
Method Summary
Modifier and Type Method Description final String
getName()
final Unit
setName(String name)
final String
getValue()
final Unit
setValue(String value)
final String
getPath()
final Unit
setPath(String path)
final Integer
getMaxAge()
final Unit
setMaxAge(Integer maxAge)
final Boolean
getSecure()
final Unit
setSecure(Boolean secure)
final Integer
getVersion()
final Unit
setVersion(Integer version)
final Boolean
isHttpOnly()
final Unit
setHttpOnly(Boolean isHttpOnly)
final String
getComment()
final Unit
setComment(String comment)
final String
getDomain()
final Unit
setDomain(String domain)
final SameSite
getSameSite()
final Unit
setSameSite(SameSite sameSite)
-
-
Constructor Detail
-
Cookie
Cookie(String name, String value, String path, Integer maxAge, Boolean secure, Integer version, Boolean isHttpOnly, String comment, String domain, SameSite sameSite)
- Parameters:
name
- the name of the cookievalue
- the value of the cookiepath
- indicates the path that must exist in the requested URL for the browser to send the Cookie header.maxAge
- indicates the number of seconds until the cookie expires.secure
- indicates that the cookie is sent to the server only when a request is made with the https: scheme (except on localhost), and therefore, is more resistant to man-in-the-middle attacks (default: false)version
- the version of the protocol this cookie complies with (default: 0)isHttpOnly
- if true, forbids JavaScript from accessing the cookie, for example, through theDocument.cookie
property.comment
- a comment that describes a cookie's purpose (default: null)domain
- defines the host to which the cookie will be sent.sameSite
- controls whether or not a cookie is sent with cross-site requests, providing some protection against cross-site request forgery attacks (CSRF).
-
Cookie
Cookie(String name, String value, String path, Integer maxAge, Boolean secure, Integer version, Boolean isHttpOnly, String comment, String domain)
- Parameters:
name
- the name of the cookievalue
- the value of the cookiepath
- indicates the path that must exist in the requested URL for the browser to send the Cookie header.maxAge
- indicates the number of seconds until the cookie expires.secure
- indicates that the cookie is sent to the server only when a request is made with the https: scheme (except on localhost), and therefore, is more resistant to man-in-the-middle attacks (default: false)version
- the version of the protocol this cookie complies with (default: 0)isHttpOnly
- if true, forbids JavaScript from accessing the cookie, for example, through theDocument.cookie
property.comment
- a comment that describes a cookie's purpose (default: null)domain
- defines the host to which the cookie will be sent.
-
Cookie
Cookie(String name, String value, String path, Integer maxAge, Boolean secure, Integer version, Boolean isHttpOnly, String comment)
- Parameters:
name
- the name of the cookievalue
- the value of the cookiepath
- indicates the path that must exist in the requested URL for the browser to send the Cookie header.maxAge
- indicates the number of seconds until the cookie expires.secure
- indicates that the cookie is sent to the server only when a request is made with the https: scheme (except on localhost), and therefore, is more resistant to man-in-the-middle attacks (default: false)version
- the version of the protocol this cookie complies with (default: 0)isHttpOnly
- if true, forbids JavaScript from accessing the cookie, for example, through theDocument.cookie
property.comment
- a comment that describes a cookie's purpose (default: null)
-
Cookie
Cookie(String name, String value, String path, Integer maxAge, Boolean secure, Integer version, Boolean isHttpOnly)
- Parameters:
name
- the name of the cookievalue
- the value of the cookiepath
- indicates the path that must exist in the requested URL for the browser to send the Cookie header.maxAge
- indicates the number of seconds until the cookie expires.secure
- indicates that the cookie is sent to the server only when a request is made with the https: scheme (except on localhost), and therefore, is more resistant to man-in-the-middle attacks (default: false)version
- the version of the protocol this cookie complies with (default: 0)isHttpOnly
- if true, forbids JavaScript from accessing the cookie, for example, through theDocument.cookie
property.
-
Cookie
Cookie(String name, String value, String path, Integer maxAge, Boolean secure, Integer version)
- Parameters:
name
- the name of the cookievalue
- the value of the cookiepath
- indicates the path that must exist in the requested URL for the browser to send the Cookie header.maxAge
- indicates the number of seconds until the cookie expires.secure
- indicates that the cookie is sent to the server only when a request is made with the https: scheme (except on localhost), and therefore, is more resistant to man-in-the-middle attacks (default: false)version
- the version of the protocol this cookie complies with (default: 0)
-
Cookie
Cookie(String name, String value, String path, Integer maxAge, Boolean secure)
- Parameters:
name
- the name of the cookievalue
- the value of the cookiepath
- indicates the path that must exist in the requested URL for the browser to send the Cookie header.maxAge
- indicates the number of seconds until the cookie expires.secure
- indicates that the cookie is sent to the server only when a request is made with the https: scheme (except on localhost), and therefore, is more resistant to man-in-the-middle attacks (default: false)
-
Cookie
Cookie(String name, String value, String path, Integer maxAge)
- Parameters:
name
- the name of the cookievalue
- the value of the cookiepath
- indicates the path that must exist in the requested URL for the browser to send the Cookie header.maxAge
- indicates the number of seconds until the cookie expires.
-
Cookie
Cookie(String name, String value, String path)
- Parameters:
name
- the name of the cookievalue
- the value of the cookiepath
- indicates the path that must exist in the requested URL for the browser to send the Cookie header.
-
-
Method Detail
-
setPath
final Unit setPath(String path)
- Parameters:
path
- indicates the path that must exist in the requested URL for the browser to send the Cookie header.
-
setMaxAge
final Unit setMaxAge(Integer maxAge)
- Parameters:
maxAge
- indicates the number of seconds until the cookie expires.
-
setSecure
final Unit setSecure(Boolean secure)
- Parameters:
secure
- indicates that the cookie is sent to the server only when a request is made with the https: scheme (except on localhost), and therefore, is more resistant to man-in-the-middle attacks (default: false)
-
getVersion
final Integer getVersion()
-
setVersion
final Unit setVersion(Integer version)
- Parameters:
version
- the version of the protocol this cookie complies with (default: 0)
-
isHttpOnly
final Boolean isHttpOnly()
-
setHttpOnly
final Unit setHttpOnly(Boolean isHttpOnly)
- Parameters:
isHttpOnly
- if true, forbids JavaScript from accessing the cookie, for example, through theDocument.cookie
property.
-
getComment
final String getComment()
-
setComment
final Unit setComment(String comment)
- Parameters:
comment
- a comment that describes a cookie's purpose (default: null)
-
setDomain
final Unit setDomain(String domain)
- Parameters:
domain
- defines the host to which the cookie will be sent.
-
getSameSite
final SameSite getSameSite()
-
setSameSite
final Unit setSameSite(SameSite sameSite)
- Parameters:
sameSite
- controls whether or not a cookie is sent with cross-site requests, providing some protection against cross-site request forgery attacks (CSRF).
-
-
-
-