Nom nom nom! The easy way to cook and eat cookies (yummy!) in #JavaScript
.
$ npm install putainde-cookie (--save-dev)
var cookie = require("putainde-cookie")
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("my-own-cookie"); // 'nom nom nom'
// bye-bye!
cookie.remove("my-own-cookie");
cookie.remove("my-own-cookie", {
domain: ".wonderland.com",
path: "/foo"
});
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')
});
Cookie designed by Caroline Lancaster from The Noun Project.