An RFC-6265 cookie store to implement the mechanism of HTTP cookie and Set-Cookie header fields as a browser does.
- A central store for different domains and paths
- Set cookies as if from a certain domain and path
- Get cookies as if from a certain domain and path
$ npm install cookie-storeconst CookieStore = require('cookie-store')
const cs = new CookieStore()
const handler = cs.from({
domain: 'bar.foo.com',
path: '/a'
})
handler.set('foo', 'a', {
domain: '.foo.com'
})
handler.get('foo').value
// 'a'- domain
String - path
String - http
Boolean=trueindicate that we will manipulate cookie via HTTP APIs. Defaults totrue
Returns Handler the cookie handler for specific domain and path.
Restarts the cookie store, and filters out session cookies.
- key
String - value
String - options
Object=- domain
String=Optional. If not specified, the cookie's host-only-flag will be set totrue - path
String=Optional. If not specified, it will - httpOnly
Boolean=falsewhether set the cookie's http-only-flag totrue - maxAge
Number - expires
Date|TimeStamp
- domain
Set a cookie.
Returns
Cookieif it has succeeded to set the cookienullif it fails to set the cookie
- setCookieHeader
Stringthe value of the HTTP Set-Cookie header.
Set a cookie via HTTP Set-Cookie header.
Returns Cookie|null as well as handler.set()
Returns Array.<Cookie> all matched cookies which have name name.
- name
String
Searches and returns the most matching cookie according to the sorting rule: https://tools.ietf.org/html/rfc6265#section-5.4
Returns
Cookieif an available cookie is foundnullif no matched cookie.
Removes all matched cookies of the name name.
Returns String the value of HTTP Cookie header
- name
- value
- domain
- path
- httpOnly
- hostOnly
- persistent
- expiryTime
The RFC-6265 cookie object.
MIT