$ cnpm install biskviit
Yet another node module for handling http cookies. This module parses Set-Cookie header, stores the data to memory and returns valid value for Cookie header based on the stored cookie data.
NB Requires Node.js v6+
Install from npm
npm install biskviit --save
Require as Biskviit
const Biskviit = require('biskviit');
Create a cookie managing biskviit instance
const biskviit = new Biskviit(options);
Where
Example
const Biskviit = require('biskviit');
const biskviit = new Biskviit({
sessionTimeout: 5 * 60 // expire cookies after 5 minutes
});
To add new cookies to the storage use set
biskviit.set(cookieString, url)
Where
Set-Cookie: headerExample
biskviit.set('theme=light', 'http://example.com/');
biskviit.set('sessionToken=abc123; Expires=Wed, 09 Jun 2021 10:18:14 GMT', 'http://example.com/');
To list all available cookies for a specified URL use get
const cookiesString = biskviit.get(url);
Where
Example
const cookiesString = biskviit.get('http://example.com/');
// theme=light; sessionToken=abc123
If you need to filter cookies as objects, use list
const cookiesString = biskviit.list(url);
Where
Example
const cookiesString = biskviit.list('http://example.com/');
// [{key: 'theme', value: 'light', expires: ...}, {key: 'sessionToken', value: 'abc123', expires: ...}]
MIT
Copyright 2013 - present © cnpmjs.org | Home |