jscookie
v1.1.0
Published
a tiny js cookie utility to get, set, and expire cookies
Downloads
189
Maintainers
Readme
jscookie
A tiny js cookie utility to get, set, and expire cookies.
How to use
Install
- NPM:
npm install jscookie
Import the module
var jscookie = require('jscookie');
Set a cookie
// 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..
Get a cookie value
jscookie.get('the_cookie_name');
Expire a cookie value
jscookie.del('the_cookie_name');