Package play.mvc

Class Http.Cookie

  • Enclosing class:
    Http

    public static class Http.Cookie
    extends Object
    HTTP Cookie
    • 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. Prefer builder(java.lang.String, java.lang.String) for creating new cookies in your application.
        Parameters:
        name - Cookie name, must not be null
        value - Cookie value
        maxAge - Cookie duration in seconds (null for a transient cookie, 0 or less for one that expires now)
        path - Cookie path
        domain - Cookie domain
        secure - 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 name
        value - 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
      • asScala

        public play.api.mvc.Cookie asScala()