Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.
/ simple-cookies Public archive

A very simple JS (or TS) library to handle cookies in the browser

License

Notifications You must be signed in to change notification settings

lapanti/simple-cookies

Repository files navigation

A very simple utility library for handling cookies in client code (JS or TS)

Greenkeeper badge Build Status License: MIT DevDependency Status Coverage Status npm npm

Install

yarn add simple-cookies

OR

npm install simple-cookies

How to use

import cookies from 'simple-cookies';

cookies.set('example', 'value' /*, cookieOpts (see below) */); // Return true if cookies are supported
cookies.get('example' /*, cookieOpts (see below) */); // Returns 'value' if cookies are supported
cookies.remove('example' /*, cookieOpts (see below) */); // Returns true if cookies are supported

Options

For each cookie-method you can pass an optional last argument that is an object with any of the following properties and values:

Name Values Effect
silent true false (default)
days a number How long the cookies should be valid (in days) optional
secure true false (default)
path a string Indicates the URL in which the cookie is used
domain a string The host(s) to whom the cookie will be sent to

License

All of the code is licensed under the MIT license

About

A very simple JS (or TS) library to handle cookies in the browser

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published