Javascript Cookie Library
JavaScript
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib Adds in domain support via #16 Jan 31, 2017
test Modernized Jan 31, 2017
.editorconfig Modernized Jan 31, 2017
.gitignore Adds in domain support via #16 Jan 31, 2017
.node-version Modernized Jan 31, 2017
.npmignore Modernized Jan 31, 2017
.travis.yml Switching dependency Feb 11, 2017
LICENSE
README.md Adds in domain support via #16 Jan 31, 2017
cookie-monster.default.js
cookie-monster.js Modernized Jan 31, 2017
package.json Switching dependency Feb 11, 2017

README.md

Cookie Monster

Build Status

Cookie manager

Installation

npm install @firstandthird/cookie-monster --save

Usage

import CookieMonster from '@firstandthird/cookie-monster';

const name = 'cookiename'; // required
const value = 'somevalue'; // required - may also be an object
const expires = 10; // optional - Days cookie is valid
const path = '/test'; // optional - defaults to /
const domain = 'blog.example.com'; // optional
const isSecure = false; // optional - sets secure flag

// Set cookie
CookieMonster.set(name, value, expires, path, domain, isSecure);

// Get cookie
CookieMonster.get(name);

// Remove cookie

CookieMonster.remove(name);

// Increment a counter cookie
CookieMonster.increment(name, expires);

// Decrement a counter cookie

CookieMonster.decrement(name, expires);

Methods can also be imported as needed:

import { get, remove } from '@firstandthird/cookie-monster';

get(name);

remove(name);