jscookie

1.1.0 • Public • Published

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');

Package Sidebar

Install

npm i jscookie

Weekly Downloads

56

Version

1.1.0

License

ISC

Last publish

Collaborators

  • devor