Interface Cookie


public interface Cookie
An HTTP cookie.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final class 
    A builder of Cookie.
  • Method Summary

    Modifier and Type
    Method
    Description
    default Timestamp
    Returns the cookie creation time since UNIX epoch.
    default String
    Returns a string that represents the domain name of this cookie or an empty string if the domain name for this cookie is not specified.
    default Timestamp
    Returns the cookie expiration time since UNIX epoch.
    default boolean
    Returns true if the cookie is considered HTTP only.
    default boolean
    Returns true if the cookie is restricted to a secure protocol (HTTPS or WSS) or false if it can be sent using any protocol.
    default String
    Returns a string that represents the name of this cookie.
    Creates a new Cookie builder.
    default String
    Returns a string that represents the path that must exist in the URL of a request in order to send this cookie to the server.
    default SameSite
    Returns the SameSite cookie attribute value.
    default String
    Returns a string that represents the value of this cookie or an empty string if the cookie value is not specified.
  • Method Details

    • newBuilder

      static Cookie.Builder newBuilder(String domain)
      Creates a new Cookie builder.
      Parameters:
      domain - a domain this cookie belongs too. Please note, that the domain is also required for cookies with __Host prefix.
      Returns:
      a new Cookie.Builder instance
      Throws:
      IllegalArgumentException - if the domain is blank or empty
    • name

      default String name()
      Returns a string that represents the name of this cookie.
      Returns:
      the name of this cookie
    • value

      default String value()
      Returns a string that represents the value of this cookie or an empty string if the cookie value is not specified.
      Returns:
      the value of this cookie or an empty string
    • domain

      default String domain()
      Returns a string that represents the domain name of this cookie or an empty string if the domain name for this cookie is not specified.
      Returns:
      the domain name of this cookie or an empty string
    • path

      default String path()
      Returns a string that represents the path that must exist in the URL of a request in order to send this cookie to the server.
    • isSecure

      default boolean isSecure()
      Returns true if the cookie is restricted to a secure protocol (HTTPS or WSS) or false if it can be sent using any protocol.
    • isHttpOnly

      default boolean isHttpOnly()
      Returns true if the cookie is considered HTTP only. It means that the cookie contains the HttpOnly attribute and should not be accessible from JavaScript.
    • creationTime

      default Timestamp creationTime()
      Returns the cookie creation time since UNIX epoch. The returned value equals the number of milliseconds since January 1, 1970.
    • expirationTime

      default Timestamp expirationTime()
      Returns the cookie expiration time since UNIX epoch. The returned value equals the number of milliseconds since January 1, 1970. Returns Timestamp.NONE for session cookies.
    • sameSite

      default SameSite sameSite()
      Returns the SameSite cookie attribute value.