JSPM

cookie-cutter

0.2.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 35209
  • Score
    100M100P100Q147582F
  • License MIT

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

Package Exports

  • cookie-cutter

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cookie-cutter) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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 expiry 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.

To unset a cookie, use a date in the past, ex: { expires: new Date(0) }

install

With npm do:

npm install cookie-cutter

license

MIT/X11