Skip to content
This repository has been archived by the owner on Apr 12, 2020. It is now read-only.

kud/cookie

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cookie

browser support

Nom nom nom! The easy way to cook and eat cookies (yummy!) in #JavaScript.

Install via npm

$ npm install putainde-cookie (--save-dev)

Usage

cookie

var cookie = require("putainde-cookie")

cookie.set(name, value[, opts])

cookie.set("my-own-cookie", "nom nom nom", {
  domain: ".wonderland.com",
  path: "/foo",
  expires: +new Date() + (cookie.DAY * 4)
});

var expires = new Date();
expires.setTime(expires.getTime() + 8 * cookie.DAY);
cookie.set("my-own-cookie", "nom nom nom", expires);
cookie.set("my-own-cookie", "nom nom nom");

cookie.get(name)

cookie.get("my-own-cookie"); // 'nom nom nom'

cookie.remove(name[, opts])

// bye-bye!
cookie.remove("my-own-cookie");
cookie.remove("my-own-cookie", {
  domain: ".wonderland.com",
  path: "/foo"
});

Sugar!

Cookie fits well with the excellent lib moment.js.

First of all, install moment:

$ bower install moment

Now, you can use something like this:

// Cookie should be eaten before the end of the day
cookie.set("gingerbread", "excellent", {
  expires: moment().endOf('day')
});

Attribution

Cookie designed by Caroline Lancaster from The Noun Project.

About

Library to manipulate cookie in JavaScript - YOU PROBABLY SHOULD USE https://github.com/js-cookie/js-cookie

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •