kooky
v0.1.4
Published
A lightweight cookie library for browser.
Downloads
2
Maintainers
Readme
kooky
A lightweight cookie library for browser.
Installation
$ npm i -P kooky
Usage
import { getCookie, setCookie, removeCookie } from 'kooky';
setCookie('key', 'value', {
expires: 2, // 2hours
path: '/',
domain: 'www.example.com',
secure: true
});
const val = getCookie('key');
removeCookie('key', {
path: '/'
});
API
setCookie(key: string, value: string, options?: object)
expires
,Number
orDate
, ifNumber
, means afterexpires
hoursdomain
, default''
path
, default'/'
secure
, defaultfalse
returns a cookie string.
getCookie(key: string)
returns the string value of cookie, if Array
, means cookie of different path
has same key, the first value is the cookie of current path
.
removeCookie(key: string, options?: object)
path
domain