Cookie (Apache Tomcat 9.0.117 API Documentation)
Description: declaration: package: org.apache.tomcat.util.http.parser, class: Cookie

# Class Cookie

java.lang.Object
org.apache.tomcat.util.http.parser.Cookie

public class Cookie extends Object

Cookie header parser based on RFC6265 and RFC2109.

The parsing of cookies using RFC6265 is more relaxed that the specification in the following ways:

- Values 0x80 to 0xFF are permitted in cookie-octet to support the use of UTF-8 in cookie values as used by HTML 5.
- For cookies without a value, the '=' is not required after the name as some browsers do not sent it.

The parsing of cookies using RFC2109 is more relaxed that the specification in the following ways:

- Values for the path attribute that contain a / character do not have to be quoted even though / is not permitted in a token.

Implementation note:
This class has been carefully tuned to ensure that it has equal or better performance than the original Netscape/RFC2109 cookie parser. Before committing and changes, ensure that the TesterCookiePerformance unit test continues to give results within 1% for the old and new parsers.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static void`
  `parseCookie(byte[] bytes, int offset, int len, ServerCookies serverCookies)`
  Deprecated.
  Unused.
  `static void`
  `parseCookie(byte[] bytes, int offset, int len, ServerCookies serverCookies, CookiesWithoutEquals cookiesWithoutEquals)`
  Parse byte array as cookie header.
  `static String`
  `unescapeCookieValueRfc2109(String input)`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### parseCookie

    @Deprecated public static void parseCookie(byte[] bytes, int offset, int len, ServerCookies serverCookies)
    Deprecated.
    Unused. This method will be removed in Tomcat 11 onwards.
    Parse byte array as cookie header.
    Parameters:
      `bytes` - Source
      `offset` - Start point in array
      `len` - Number of bytes to read
      `serverCookies` - Structure to store results

  - ### parseCookie

    public static void parseCookie(byte[] bytes, int offset, int len, ServerCookies serverCookies, CookiesWithoutEquals cookiesWithoutEquals)
    Parse byte array as cookie header.
    Parameters:
      `bytes` - Source
      `offset` - Start point in array
      `len` - Number of bytes to read
      `serverCookies` - Structure to store results
      `cookiesWithoutEquals` - How to handle a cookie name-value-pair that does not contain an equals character

  - ### unescapeCookieValueRfc2109

    public static String unescapeCookieValueRfc2109(String input)