Exciting news!Announcing our $4.6M Series Seed. Learn more
Socket
LoveBlogFAQ
Install
Log in

set-cookie-header

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Issues
File Explorer

Advanced tools

set-cookie-header

Decode and encode Set-Cookie headers

    0.0.1latest

Version published
Maintainers
1
Yearly downloads
10,068
increased by564.99%

Weekly downloads

Readme

Source

set-cookie-header

Decode and encode Set-Cookie headers. Aligns with RFC6265.

Install

npm install set-cookie-header

Quick Start

import {encode, decode} from 'set-cookie-header'; const cookies = decode('foo=bar; Max-Age=1234; Domain=.example.com; Path=/; Expires=December 17, 1995 03:24:00 GMT; HttpOnly'); for (const cookie of cookies) { cookie.secure = true; const encoded = encoded(cookie); }

API

decode(cookieHeader: string | string[]): Cookie[]

Accepts:

  • cookieHeader can be a raw Set-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.

Keywords

Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc