Interface Cookie

All Superinterfaces:
java.lang.Comparable<Cookie>
All Known Subinterfaces:
Cookie
All Known Implementing Classes:
DefaultCookie, DefaultCookie

public interface Cookie extends java.lang.Comparable<Cookie>
An interface defining an HTTP cookie.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final long
    Constant for undefined MaxAge attribute value.
  • Method Summary

    Modifier and Type
    Method
    Description
    java.lang.String
    Returns the domain of this Cookie.
    boolean
    Checks to see if this Cookie can only be accessed via HTTP.
    boolean
    Checks to see if this Cookie is secure
    long
    Returns the maximum age of this Cookie in seconds or UNDEFINED_MAX_AGE if unspecified
    java.lang.String
    Returns the name of this Cookie.
    java.lang.String
    Returns the path of this Cookie.
    void
    setDomain(java.lang.String domain)
    Sets the domain of this Cookie.
    void
    setHttpOnly(boolean httpOnly)
    Determines if this Cookie is HTTP only.
    void
    setMaxAge(long maxAge)
    Sets the maximum age of this Cookie in seconds.
    void
    setPath(java.lang.String path)
    Sets the path of this Cookie.
    void
    setSecure(boolean secure)
    Sets the security getStatus of this Cookie
    void
    setValue(java.lang.String value)
    Sets the value of this Cookie.
    void
    setWrap(boolean wrap)
    Sets true if the value of this Cookie is to be wrapped with double quotes.
    java.lang.String
    Returns the value of this Cookie.
    boolean
    Returns true if the raw value of this Cookie, was wrapped with double quotes in original Set-Cookie header.

    Methods inherited from interface java.lang.Comparable

    compareTo
  • Field Details

    • UNDEFINED_MAX_AGE

      static final long UNDEFINED_MAX_AGE
      Constant for undefined MaxAge attribute value.
      See Also:
  • Method Details

    • name

      java.lang.String name()
      Returns the name of this Cookie.
      Returns:
      The name of this Cookie
    • value

      java.lang.String value()
      Returns the value of this Cookie.
      Returns:
      The value of this Cookie
    • setValue

      void setValue(java.lang.String value)
      Sets the value of this Cookie.
      Parameters:
      value - The value to set
    • wrap

      boolean wrap()
      Returns true if the raw value of this Cookie, was wrapped with double quotes in original Set-Cookie header.
      Returns:
      If the value of this Cookie is to be wrapped
    • setWrap

      void setWrap(boolean wrap)
      Sets true if the value of this Cookie is to be wrapped with double quotes.
      Parameters:
      wrap - true if wrap
    • domain

      java.lang.String domain()
      Returns the domain of this Cookie.
      Returns:
      The domain of this Cookie
    • setDomain

      void setDomain(java.lang.String domain)
      Sets the domain of this Cookie.
      Parameters:
      domain - The domain to use
    • path

      java.lang.String path()
      Returns the path of this Cookie.
      Returns:
      The Cookie's path
    • setPath

      void setPath(java.lang.String path)
      Sets the path of this Cookie.
      Parameters:
      path - The path to use for this Cookie
    • maxAge

      long maxAge()
      Returns the maximum age of this Cookie in seconds or UNDEFINED_MAX_AGE if unspecified
      Returns:
      The maximum age of this Cookie
    • setMaxAge

      void setMaxAge(long maxAge)
      Sets the maximum age of this Cookie in seconds. If an age of 0 is specified, this Cookie will be automatically removed by browser because it will expire immediately. If UNDEFINED_MAX_AGE is specified, this Cookie will be removed when the browser is closed.
      Parameters:
      maxAge - The maximum age of this Cookie in seconds
    • isSecure

      boolean isSecure()
      Checks to see if this Cookie is secure
      Returns:
      True if this Cookie is secure, otherwise false
    • setSecure

      void setSecure(boolean secure)
      Sets the security getStatus of this Cookie
      Parameters:
      secure - True if this Cookie is to be secure, otherwise false
    • isHttpOnly

      boolean isHttpOnly()
      Checks to see if this Cookie can only be accessed via HTTP. If this returns true, the Cookie cannot be accessed through client side script - But only if the browser supports it. For more information, please look here
      Returns:
      True if this Cookie is HTTP-only or false if it isn't
    • setHttpOnly

      void setHttpOnly(boolean httpOnly)
      Determines if this Cookie is HTTP only. If set to true, this Cookie cannot be accessed by a client side script. However, this works only if the browser supports it. For information, please look here.
      Parameters:
      httpOnly - True if the Cookie is HTTP only, otherwise false.