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, or an empty string if the cookie name is not specified.
    Creates a new Cookie builder.
    Returns the partition key if the cookie has the independent partitioned state.
    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 to. Please note, 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, or an empty string if the cookie name is not specified.
      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.
    • partitionKey

      default Optional<PartitionKey> partitionKey()
      Returns the partition key if the cookie has the independent partitioned state. Otherwise, returns Optional.empty()

      Partitioned cookies are Secure cookies with the Partitioned attribute that can be set in another embedded frame context.

      Since:
      7.40.0