https://github.com/firstandthird/cookie-monster
Javascript Cookie Library
https://github.com/firstandthird/cookie-monster
front-end
Last synced: 12 months ago
JSON representation
Javascript Cookie Library
- Host: GitHub
- URL: https://github.com/firstandthird/cookie-monster
- Owner: firstandthird
- License: mit
- Created: 2011-10-13T23:24:17.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2020-04-27T12:03:06.000Z (almost 6 years ago)
- Last Synced: 2025-04-11T01:12:15.294Z (12 months ago)
- Topics: front-end
- Language: JavaScript
- Homepage:
- Size: 138 KB
- Stars: 74
- Watchers: 15
- Forks: 24
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Cookie Monster
[](https://travis-ci.org/firstandthird/cookie-monster)

Cookie manager
## Installation
```sh
npm install @firstandthird/cookie-monster
```
## Usage
```js
import CookieMonster from '@firstandthird/cookie-monster';
const name = 'cookiename'; // required
const value = 'somevalue'; // required - may also be an object
const expires = 10; // optional - Days cookie is valid
const path = '/test'; // optional - defaults to /
const domain = 'blog.example.com'; // optional
const isSecure = false; // optional - sets secure flag
const sameSite = 'Strict'; // optional - defaults to 'Strict' - Valid values: 'None', 'Lax', 'Strict'
// Set cookie
CookieMonster.set(name, value, expires, path, domain, isSecure, sameSite);
// Get cookie
CookieMonster.get(name);
// Remove cookie
CookieMonster.remove(name);
// Increment a counter cookie
CookieMonster.increment(name, expires);
// Decrement a counter cookie
CookieMonster.decrement(name, expires);
```
Methods can also be imported as needed:
```js
import { get, remove } from '@firstandthird/cookie-monster';
get(name);
remove(name);
```