Interface HttpResponseCookie

All Known Implementing Classes:
WritableHttpCookie

public interface HttpResponseCookie

Cookie to send in the HttpResponse.

Cookie follows RFC 6265

Author:
Daniel Sagenschneider
  • Field Details

    • BROWSER_SESSION_MAX_AGE

      static final long BROWSER_SESSION_MAX_AGE
      Value of Max-Age indicating no age expire and should expire with the browser session.
      See Also:
  • Method Details

    • getName

      String getName()
      Obtains the name.
      Returns:
      Name.
    • getValue

      String getValue()
      Obtains the value.
      Returns:
      Value.
    • setValue

      HttpResponseCookie setValue(String value)
      Sets the value.
      Parameters:
      value - Value.
      Returns:
      this.
    • getExpires

      TemporalAccessor getExpires()
      Obtains the expire time.
      Returns:
      Expire time. May be null if no expire.
    • setExpires

      HttpResponseCookie setExpires(TemporalAccessor expires)
      Sets the expire time.
      Parameters:
      expires - Expires time.
      Returns:
      this.
    • getMaxAge

      long getMaxAge()
      Obtains the maximum age in seconds.
      Returns:
      Maximum age in seconds. Will be BROWSER_SESSION_MAX_AGE if not specified.
    • setMaxAge

      HttpResponseCookie setMaxAge(long maxAge)

      Sets the maximum age in seconds.

      As per RFC 6265 this overrides Expires.

      Parameters:
      maxAge - Maximum age in seconds.
      Returns:
      this.
    • getDomain

      String getDomain()
      Obtains the domain.
      Returns:
      Domain. May be null.
    • setDomain

      HttpResponseCookie setDomain(String domain)
      Specifies the domain.
      Parameters:
      domain - Domain.
      Returns:
      this.
    • getPath

      String getPath()
      Obtains the path.
      Returns:
      Path. May be null.
    • setPath

      HttpResponseCookie setPath(String path)
      Specifies the path.
      Parameters:
      path - Path.
      Returns:
      this.
    • isSecure

      boolean isSecure()

      Indicates if only communicated across secure a secure connection.

      Note that, as per RFC 6265, this does not guarantee the security of the cookie contents. Cookies, as per the specification, are inherently insecure (such as any information sent to the client).

      Returns:
      true to only communicate this Cookie across a secure connection.
    • setSecure

      HttpResponseCookie setSecure(boolean isSecure)
      Flags whether the client is only to send the Cookie over a secure connection.
      Parameters:
      isSecure - true to request the client to only send this Cookie over a secure connection (assuming the client supports this).
      Returns:
      this.
    • isHttpOnly

      boolean isHttpOnly()
      Indicates if the Cookie is only sent over HTTP connection.
      Returns:
      true to only make this Cookie available in HTTP requests.
    • setHttpOnly

      HttpResponseCookie setHttpOnly(boolean isHttpOnly)
      Indicates if only available over HTTP requests (and not, for example, made available to JavaScript in the browser).
      Parameters:
      isHttpOnly - true to request the client to only send this Cookie in HTTP requests, and not, for example, make available to JavaScript in the browser.
      Returns:
      this.
    • addExtension

      HttpResponseCookie addExtension(String extension)

      Allows adding an extension.

      The extensions are added as provided (separated by ';') to the end of the Set-Cookie HttpHeader.

      Parameters:
      extension - Extension.
      Returns:
      this.
    • getExtensions

      String[] getExtensions()
      Obtains the extensions.
      Returns:
      Extensions.
    • clearAttributes

      HttpResponseCookie clearAttributes()
      Clears the attributes.
      Returns:
      this.
    • configure

      Enables configuring multiple attributes with reduced locking.
      Parameters:
      configurer - Consumer to configured the HttpResponseCookie.
      Returns:
      this.