set-cookie-header
Decode and encode
Set-Cookie
headers. Aligns with RFC6265.
Install
npm install set-cookie-header
Quick Start
; ; for of cookies
API
decode(cookieHeader: string | string[]): Cookie[]
Accepts:
cookieHeader
can be a rawSet-Cookie
header, the value of the header, or an array of header values.- Eg:
'Set-Cookie: foo=bar; Path=/'
'foo=bar; Secure'
['foo=bar', 'biz=baz']
Returns:
- Array of decoded
Cookie
objects.
encode(cookie: Cookie | Cookie[]): string[]
Accepts:
- An array or a single
Cookie
object.
Returns:
- Array of encoded cookie strings.