A tiny js cookie utility to get, set, and expire cookies.
- NPM:
npm install jscookie
var jscookie = require('jscookie');
// Simple Session Cookie
jscookie.set({
name : 'the_cookie_name',
value : 'cookie value'
});
or
// Advanced Options
jscookie.set({
name : 'the_cookie_name',
value : 'cookie value',
exdays : 5;
path : '/',
domain : 'http://thisdomain.com'
});
Setting a cookie exdays to false
, or ommitting the property, will create a session only cookie..
jscookie.get('the_cookie_name');
jscookie.del('the_cookie_name');