HTTP Set-Cookie Serializer
Serialize one cookie pair and explicit attributes while rejecting characters that can create additional header fields.
Description
Set-Cookie sends one cookie pair from server to client with optional attributes.
When to use HTTP Set-Cookie Serializer
Use this tool to serialize one cookie pair and explicit attributes while rejecting characters that can create additional header fields.
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 Serializer 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 name, value, attributes using the field table and calculation rules, then run the tool.
- Read header. 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 |
|---|---|---|---|
| name | Cookie name. | string; maximum length: 1000000 | Required |
| value | Cookie value. | string; maximum length: 1000000 | Required |
| attributes | Cookie attributes; an empty value emits a flag. | list of object; minimum entries: 0; maximum entries: 100000 | Required |
Enter a nonempty ASCII token name, valid cookie value and ordered attribute objects with name/value fields. Cookie values may be empty but reject whitespace, quotation marks, comma, semicolon, backslash, controls and non-ASCII. Attribute names are tokens; values allow printable ASCII except semicolon. Return one header field value; preserve attribute spelling, order and duplicates.3
header=name=value + ordered ; attribute[=value] fragments Units, indexing, boundary conditions and exceptional cases are defined in the calculation rules above.
| Output field | Meaning | Value type |
|---|---|---|
| header | Serialized Set-Cookie field value. | string; maximum length: 1000000 |
{
"input": {
"name": "theme",
"value": "dark",
"attributes": [
{
"name": "Path",
"value": "/"
},
{
"name": "Secure",
"value": ""
}
]
},
"output": {
"header": "theme=dark; Path=/; Secure"
}
} Limitations and assumptions
No escaping, encoding, cookie storage or attribute semantics are supplied. Expires, SameSite, domain/path and prefix rules require separate validation.
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 Parser: Parse one Set-Cookie field into its cookie pair and ordered attributes, preserving extensions and Expires text. For a complementary task, use HTTP Cookie Serializer: Serialize ordered cookie pairs using RFC 6265 cookie octets without implicit escaping or decoding.
Further background: RFC 6265: HTTP State Management Mechanism.
References
-
HTTP Set-Cookie Serializer — tool.io
-
RFC 6265: HTTP State Management Mechanism — Internet Engineering Task Force
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 Cookie Serializer
Serialize ordered cookie pairs using RFC 6265 cookie octets without implicit escaping or decoding.