0.6.0 • Published 7 years ago

simple-cookies v0.6.0

Weekly downloads
17
License
MIT
Repository
github
Last release
7 years ago

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

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:

NameValuesEffect
silenttruefalse (default)Whether to throw an error (false) or not (true) when cookies are not supported
daysa numberHow long the cookies should be valid (in days) optional
securetruefalse (default)Whether the cookie should only be transmitted over secure protocols such as https
patha stringIndicates the URL in which the cookie is used
domaina stringThe host(s) to whom the cookie will be sent to

License

All of the code is licensed under the MIT license

0.6.0

7 years ago

0.5.0

7 years ago

0.4.0

7 years ago

0.3.0

7 years ago