Package play.mvc
Class Http.Cookie
- Object
-
- play.mvc.Http.Cookie
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Http.Cookie.SameSite
The cookie SameSite attribute
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description play.api.mvc.Cookie
asScala()
static Http.CookieBuilder
builder(String name, String value)
String
domain()
boolean
httpOnly()
Integer
maxAge()
String
name()
String
path()
Optional<Http.Cookie.SameSite>
sameSite()
boolean
secure()
String
value()
-
-
-
Constructor Detail
-
Cookie
public Cookie(String name, String value, Integer maxAge, String path, String domain, boolean secure, boolean httpOnly, Http.Cookie.SameSite sameSite)
Construct a new cookie. Preferbuilder(java.lang.String, java.lang.String)
for creating new cookies in your application.- Parameters:
name
- Cookie name, must not be nullvalue
- Cookie valuemaxAge
- Cookie duration in seconds (null for a transient cookie, 0 or less for one that expires now)path
- Cookie pathdomain
- Cookie domainsecure
- Whether the cookie is secured (for HTTPS requests)httpOnly
- Whether the cookie is HTTP only (i.e. not accessible from client-side JavaScript code)sameSite
- the SameSite attribute for this cookie (for CSRF protection).
-
-
Method Detail
-
builder
public static Http.CookieBuilder builder(String name, String value)
- Parameters:
name
- the cookie builder namevalue
- the cookie builder value- Returns:
- the cookie builder with the specified name and value
-
name
public String name()
- Returns:
- the cookie name
-
value
public String value()
- Returns:
- the cookie value
-
maxAge
public Integer maxAge()
- Returns:
- the cookie expiration date in seconds, null for a transient cookie, a value less than zero for a cookie that expires now
-
path
public String path()
- Returns:
- the cookie path
-
domain
public String domain()
- Returns:
- the cookie domain, or null if not defined
-
secure
public boolean secure()
- Returns:
- wether the cookie is secured, sent only for HTTPS requests
-
httpOnly
public boolean httpOnly()
- Returns:
- wether the cookie is HTTP only, i.e. not accessible from client-side JavaScript code
-
sameSite
public Optional<Http.Cookie.SameSite> sameSite()
- Returns:
- the SameSite attribute for this cookie
-
asScala
public play.api.mvc.Cookie asScala()
-
-