Serializes a cookie into a Set-Cookie header value.
Set-Cookie
The value is percent-encoded, so a payload containing ;, ,, or whitespace can neither inject attributes nor split the header.
;
,
Cookie name; must match RFC 6265's token production
token
Cookie value; percent-encoded on the way out
Attributes to emit; omitted fields emit no attribute
The Set-Cookie header value
If name is not a valid cookie name, or maxAge is not an integer
name
maxAge
serializeCookie('sid', 'abc', { path: '/', httpOnly: true, sameSite: 'lax', maxAge: 3600 });// → 'sid=abc; Max-Age=3600; Path=/; HttpOnly; SameSite=Lax' Copy
serializeCookie('sid', 'abc', { path: '/', httpOnly: true, sameSite: 'lax', maxAge: 3600 });// → 'sid=abc; Max-Age=3600; Path=/; HttpOnly; SameSite=Lax'
0.2.0
Serializes a cookie into a
Set-Cookieheader value.The value is percent-encoded, so a payload containing
;,,, or whitespace can neither inject attributes nor split the header.