Interface Cookie


  • public interface Cookie
    Framework-agnostic definition of a cookie. Creates a cookie, a small amount of information sent by a servlet to a Web browser, saved by the browser, and later sent back to the server. A cookie's value can uniquely identify a client, so cookies are commonly used for session management.
    Since:
    9.16
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      int getMaxAge()
      Gets the maximum age in seconds of this Cookie.
      java.lang.String getName()
      Returns the name of the cookie.
      java.lang.String getPath()
      Returns the path on the server to which the browser returns this cookie.
      java.lang.String getValue()
      Gets the current value of this Cookie.
      boolean isHttpOnly()
      Checks whether this Cookie has been marked as HttpOnly.
      boolean isSecure()
      Returns true if the browser is sending cookies only over a secure protocol, or false if the browser can send cookies using any protocol.
    • Method Detail

      • getName

        java.lang.String getName()
        Returns the name of the cookie. The name cannot be changed after creation.
      • getValue

        java.lang.String getValue()
        Gets the current value of this Cookie.
      • getPath

        java.lang.String getPath()
        Returns the path on the server to which the browser returns this cookie. The cookie is visible to all subpaths on the server.
      • isSecure

        boolean isSecure()
        Returns true if the browser is sending cookies only over a secure protocol, or false if the browser can send cookies using any protocol.
      • isHttpOnly

        boolean isHttpOnly()
        Checks whether this Cookie has been marked as HttpOnly.
      • getMaxAge

        int getMaxAge()
        Gets the maximum age in seconds of this Cookie.