HTTP Set-Cookie Parser
Parse one Set-Cookie field into its cookie pair and ordered attributes, preserving extensions and Expires text.
Description
A Set-Cookie field carries one cookie pair and attribute parameters.
When to use HTTP Set-Cookie Parser
Use this tool to parse one Set-Cookie field into its cookie pair and ordered attributes, preserving extensions and Expires text.
Prepare the header field value, cookie records or status code requested. Supply field values without a header-name prefix and preserve syntax for the parser to inspect.
How to use HTTP Set-Cookie Parser and understand its results
- Prepare the header field value, cookie records or status code requested. Supply field values without a header-name prefix and preserve syntax for the parser to inspect.
- Enter header using the field table and calculation rules, then run the tool.
- Read name, value, attributes. 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 | One Set-Cookie field value; combined fields are not supported. | string; maximum length: 1000000 | Required |
Paste one field value. Reject CR, LF and NUL; parse the first equals sign, trim name/value and remove matching surrounding double quotes from the cookie value. Validate cookie octets. Trim attributes, lowercase names and retain values/order/duplicates; flag attributes have empty values. Return name, value and attributes.3
split on semicolons; first part=cookie pair; remaining parts=attributes Units, indexing, boundary conditions and exceptional cases are defined in the calculation rules above.
| Output field | Meaning | Value type |
|---|---|---|
| name | Cookie name. | string; maximum length: 1000000 |
| value | Cookie value. | string; maximum length: 1000000 |
| attributes | Attributes with lowercase names and empty values for flags. | list of object; minimum entries: 0; maximum entries: 100000 |
{
"input": {
"header": "session=abc; Path=/; Secure; HttpOnly; SameSite=Lax"
},
"output": {
"name": "session",
"value": "abc",
"attributes": [
{
"name": "path",
"value": "/"
},
{
"name": "secure",
"value": ""
},
{
"name": "httponly",
"value": ""
},
{
"name": "samesite",
"value": "Lax"
}
]
}
} Limitations and assumptions
No percent-decoding, browser acceptance, expiration-date parsing or cookie policy is assessed. Combined Set-Cookie fields are unsupported, and a trailing empty attribute fails.
Numeric inputs must be finite. Follow the calculation-specific rules for overflow, underflow and exceptional cases. Extremely large text inputs are rejected. Missing required fields, extra fields, wrong value types and violations of the calculation rules are input errors.
Alternative or Complementary methods
Use HTTP Set-Cookie Serializer: Serialize one cookie pair and explicit attributes while rejecting characters that can create additional header fields. For a complementary task, use HTTP Cookie Parser: Parse a Cookie header into ordered name and value pairs while preserving duplicate cookie names and encoded values.
Further background: RFC 6265: HTTP State Management Mechanism.
References
-
HTTP Set-Cookie Parser — tool.io
-
RFC 6265: HTTP State Management Mechanism — Internet Engineering Task Force
Similar or alternative tools
- HTTP Set-Cookie Serializer
Serialize one cookie pair and explicit attributes while rejecting characters that can create additional header fields.
- HTTP Cookie Parser
Parse a Cookie header into ordered name and value pairs while preserving duplicate cookie names and encoded values.