npm install @ferrow/cookie-parse-liteHTTP cookie parsing and serialization with Set-Cookie attribute support and SameSite validation.
import { parse, serialize } from "cookie-parse-lite";
const cookies = parse("sessionId=abc123; theme=dark");
const setHeader = serialize("token", "xyz", {
httpOnly: true,
secure: true,
sameSite: "Strict",
});Parse a Cookie request header into a name→value map.
Create a Set-Cookie header string. Enforces SameSite=None requires Secure flag.
Parse a Set-Cookie response header into structured form with name, value, and attributes.
interface CookieAttributes {
maxAge?: number // Seconds
expires?: Date // Absolute expiry
domain?: string // Domain restriction
path?: string // Path restriction
secure?: boolean // HTTPS only
httpOnly?: boolean // No JS access
sameSite?: "Strict" | "Lax" | "None"
}- No domain/path matching (scope checking is app responsibility)
- Attribute parsing case-insensitive (per spec)
- SameSite=None+Secure validation at serialize time only
Part of the ferrow-toolkit collection · Sponsored by Ferrow