org.apache.hc.client5.http.cookie

## Interface Cookie

- All Known Subinterfaces:
    SetCookie
  All Known Implementing Classes:
    BasicClientCookie

      public interface Cookie

  Cookie interface represents a token or short packet of state information (also referred to as "magic-cookie") that the HTTP agent and the target server can exchange to maintain a session. In its simples form an HTTP cookie is merely a name / value pair.
  Since:
    4.0

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `DOMAIN_ATTR`
    `static String` | `EXPIRES_ATTR`
    `static String` | `MAX_AGE_ATTR`
    `static String` | `PATH_ATTR`
    `static String` | `SECURE_ATTR`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `containsAttribute(String name)`
    `String` | `getAttribute(String name)`
    `Date` | `getCreationDate()` Returns creation time of the cookie.
    `String` | `getDomain()` Returns domain attribute of the cookie.
    `Date` | `getExpiryDate()` Returns the expiration `Date` of the cookie, or `null` if none exists.
    `String` | `getName()` Returns the name.
    `String` | `getPath()` Returns the path attribute of the cookie.
    `String` | `getValue()` Returns the value.
    `boolean` | `isExpired(Date date)` Returns true if this cookie has expired.
    `boolean` | `isPersistent()` Returns `false` if the cookie should be discarded at the end of the "session"; `true` otherwise.
    `boolean` | `isSecure()` Indicates whether this cookie requires a secure connection.

- - ### Field Detail

    - #### PATH_ATTR

          static final String PATH_ATTR

      See Also:
        Constant Field Values

    - #### DOMAIN_ATTR

          static final String DOMAIN_ATTR

      See Also:
        Constant Field Values

    - #### MAX_AGE_ATTR

          static final String MAX_AGE_ATTR

      See Also:
        Constant Field Values

    - #### SECURE_ATTR

          static final String SECURE_ATTR

      See Also:
        Constant Field Values

    - #### EXPIRES_ATTR

          static final String EXPIRES_ATTR

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### getAttribute

          String getAttribute(String name)

      Since:
        5.0

    - #### containsAttribute

          boolean containsAttribute(String name)

      Since:
        5.0

    - #### getName

          String getName()

      Returns the name.
      Returns:
        String name The name

    - #### getValue

          String getValue()

      Returns the value.
      Returns:
        String value The current value.

    - #### getExpiryDate

          Date getExpiryDate()

      Returns the expiration `Date` of the cookie, or `null` if none exists.

      Note: the object returned by this method is considered immutable. Changing it (e.g. using setTime()) could result in undefined behaviour. Do so at your peril.

      Returns:
        Expiration `Date`, or `null`.

    - #### isPersistent

          boolean isPersistent()

      Returns `false` if the cookie should be discarded at the end of the "session"; `true` otherwise.
      Returns:
        `false` if the cookie should be discarded at the end of the "session"; `true` otherwise

    - #### getDomain

          String getDomain()

      Returns domain attribute of the cookie. The value of the Domain attribute specifies the domain for which the cookie is valid.
      Returns:
        the value of the domain attribute.

    - #### getPath

          String getPath()

      Returns the path attribute of the cookie. The value of the Path attribute specifies the subset of URLs on the origin server to which this cookie applies.
      Returns:
        The value of the path attribute.

    - #### isSecure

          boolean isSecure()

      Indicates whether this cookie requires a secure connection.
      Returns:
        `true` if this cookie should only be sent over secure connections, `false` otherwise.

    - #### isExpired

          boolean isExpired(Date date)

      Returns true if this cookie has expired.
      Parameters:
        `date` - Current time
      Returns:
        `true` if the cookie has expired.

    - #### getCreationDate

          Date getCreationDate()

      Returns creation time of the cookie.

Copyright © 1999–2021 The Apache Software Foundation. All rights reserved.