Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including gcookie with all npm packages installed. Try it out:

var gcookie = require("gcookie")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

gcookie v0.2.0

The tiniest cookie library

Glorious Cookie

CircleCI Test Coverage Code Climate

Install

Glorious Cookie is available via npm:

npm i gcookie --save

Once installed, you just need insert it on your page:

<script src="/node_modules/gcookie/dist/gcookie.min.js"></script>

Usage

Intending to be as simple as possible, Glorious Cookie has only three methods.

Set

/*
** @key: String [required]
** @value: String [required]
** @days: Number [optional] - If not provided, cookie is removed when the user closes the browser.
** @path: String [optional] - If not provided, cookie is valid for the entire site.
*/
gcookie.set(key, value, days, path);

Get

/*
** @key: String [optional] - If not provided, all cookies will be returned.
*/
gcookie.get(key);

Remove

/*
** @key: String [required]
** @path: String [optional] - If you have specified a path on gcookie.set(),
**                            it will be required here.
*/
gcookie.remove(key, path);

Note: If cookies are not available, a warning will be logged when trying to set or remove a cookie.

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free