GithubHelp home page GithubHelp logo

cshenoy / 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 116 KB

Me want cookie!

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

License: MIT License

HTML 3.41% JavaScript 96.59%

cookie-monster's Introduction

cookie-monster

Build 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 .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-monster

test

With the console do

$ npm test

license

MIT/X11

cookies

cookie-monster

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.