Coder Social home page Coder Social logo

jacobrask / cookie-monster Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kahnvex/cookie-monster

0.0 2.0 0.0 25 KB

Me want cookie!

Home Page: https://www.npmjs.org/package/cookie-monster

License: MIT License

HTML 2.29% JavaScript 97.71%

cookie-monster's Introduction

cookie-monster

Build Status Dependencies Status devDependencies Status

NOTE: cookie-monster is a fork of cookie-cutter by substack (James Halliday), which seems to have gone stale.

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

In your browser code with browserify:

var cookie = require('cookie-monster');
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-monster');

cookie(document)

Return a new cookie object with .getItem(), .setItem(), .removeItem() and .clear() operating on document. Older version's .get(), .set() and .remove() methods are left for backward compatibility, but their usage is highly discouraged.

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.getItem(key)

Return the cookie value for key. Aliased by cookie.get().

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

Set the cookie at key to value with optional parameters expires and path. Aliased by cookie.set().

cookie.removeItem(key)

Removes cookie value stored at key. Aliased by cookie.remove().

Alternatively you can use .setItem() with { expires: new Date(0) } option to unset a cookie.

cookie.clear()

Removes all currently available cookies.

install

With npm do:

npm install cookie-monster

test

With the console do

$ npm test

license

MIT/X11

cookies

cookie-monster

cookie-monster's People

Contributors

cameronr avatar ccheever avatar euwest avatar iclanzan avatar jasonkarns avatar kahnvex avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.