0.1.4 • Published 5 years ago

kooky v0.1.4

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

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 or Date, if Number, means after expires hours
  • domain, default ''
  • path, default '/'
  • secure, default false

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
0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

6 years ago