Cookie(name, value, path, maxAge, isSecure, SameSite)

Creates a new instance of the Cookie class using the specified name, value, path, and age, and settings for security and cross-domain behavior.

Signature

Google Chrome 80 introduces a new default cookie attribute setting of SameSite, which is set to Lax. Previously, the SameSite cookie attribute defaulted to the value of None. When SameSite is set to None, cookies must be tagged with the isSecure attribute indicating that they require an encrypted HTTPS connection.

Note

public Cookie(String name, String value, String path, Integer maxAge, Boolean isSecure, String SameSite)

Parameters

name
Type: String
The cookie name. It can’t be null.
value
Type: String
The cookie data, such as session ID.
path
Type: String
The path from where you can retrieve the cookie.
maxAge
Type: Integer
A number representing how long a cookie is valid for in seconds. If set to less than zero, a session cookie is issued. If set to zero, the cookie is deleted.
isSecure
Type: Boolean
A value indicating whether the cookie can only be accessed through HTTPS (true) or not (false).
SameSite
Type: String
The SameSite attribute on a cookie controls its cross-domain behavior. The valid values are None, Lax, and Strict. After the Chrome 80 release, a cookie with a SameSite value of None must also be marked secure by setting a value of None; Secure.