HTTP Cookie Parser
Parse a Cookie header into ordered name and value pairs while preserving duplicate cookie names and encoded values.
Description
A request Cookie header contains ordered name/value pairs.
When to use HTTP Cookie Parser
Use HTTP Cookie Parser when you need to evaluate the supplied records under the calculation and evidence rules below. No Set-Cookie attributes, expiry, cookie-store policy, URL decoding or authentication is evaluated. Trailing semicolons and malformed pairs are errors.
Paste the requested HTTP header field value. Use the field table to distinguish request cookies, media types and authorization credentials.
How to use HTTP Cookie Parser and understand its results
- Paste the requested HTTP header field value. Use the field table to distinguish request cookies, media types and authorization credentials.
- Enter header using the field table and calculation rules, then run the tool.
- Read cookies. The explanation below defines the units, signs, ordering and any flags or placeholder values.
- If the tool reports an input issue, correct the values and run it again. Apply the stated assumptions when interpreting a successfully returned result.
| Input field | Meaning | Value type; see rules below | Requirement |
|---|---|---|---|
| header | Cookie field value. | string; maximum length: 1000000 | Required |
Paste only the field value. Blank input returns an empty list. Reject control characters; split on semicolons and each pair's first equals sign. Trim name/value, remove matched outer double quotes and validate ASCII token names/cookie-octet values. Preserve duplicates, case, further equals signs and percent encoding.
cookies=semicolon-separated valid pairs in source order Units, indexing, boundary conditions and exceptional cases are defined in the calculation rules above.
| Output field | Meaning | Value type |
|---|---|---|
| cookies | Cookie pairs in source order. | list of object; minimum entries: 0; maximum entries: 100000 |
| cookies[].name | Field in cookies record | string; maximum length: 1000000 |
| cookies[].value | Field in cookies record | string; maximum length: 1000000 |
{
"input": {
"header": "session=abc%20123; theme=dark; session=second"
},
"output": {
"cookies": [
{
"name": "session",
"value": "abc%20123"
},
{
"name": "theme",
"value": "dark"
},
{
"name": "session",
"value": "second"
}
]
}
} Limitations and assumptions
No Set-Cookie attributes, expiry, cookie-store policy, URL decoding or authentication is evaluated. Trailing semicolons and malformed pairs are errors.
Numeric inputs, where present, must be finite. Follow the calculation-specific rules for overflow, underflow and exceptional cases. Extremely large text inputs are rejected. Missing fields without a declared default, extra fields, wrong value types and violations of the calculation rules are input errors.
Alternative or Complementary methods
Use HTTP Set-Cookie Parser: Parse one Set-Cookie field into its cookie pair and ordered attributes, preserving extensions and Expires text. For a complementary task, use HTTP Content-Type Parser: A Content-Type field identifies a media type plus optional parameters such as charset or boundary. Parameter name normalization must not alter parameter values.
Further background: RFC 6265: HTTP State Management Mechanism.
References
-
HTTP Cookie Parser — tool.io
Similar or alternative tools
- HTTP Set-Cookie Parser
Parse one Set-Cookie field into its cookie pair and ordered attributes, preserving extensions and Expires text.
- HTTP Content-Type Parser
A Content-Type field identifies a media type plus optional parameters such as charset or boundary. Parameter name normalization must not alter parameter values.