Skip to content

ccheever/cookie-cutter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

cookie-cutter

Set and get cookies in the browser or in node with document.

In your browser code with browserify:

var cookie = require('cookie-cutter');
var times = parseInt(cookie.get('times'), 10) || 0;
cookie.set('times', times + 1);

and times will increment every time the page is reloaded.

methods

var cookie = require('cookie-cutter');

cookie(document)

Return a new cookie object with .get() and .set() operating on document.

document.cookie should be a non-referentially transparent setter/getter combo like the DOM's variant where assignment with optional path and expires creates a new cookie in the getter as a key=value pair.

cookie.get(key)

Return the cookie value for key.

cookie.set(key, value, opts={})

Set the cookie at key to value with optional parameters expires and path.

cookie.delete(key)

Unsets the cookie at key by setting its expires to a date in the past.

install

With npm do:

npm install cookie-cutter

license

MIT/X11

About

Browserify-compatible module to get and set cookies in the browser

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%