nanocookie
v0.0.11
Published
nano vanilla.js cookie library
Downloads
12
Readme
nanocookie
nano cookie operate library
nano vanilla.js cookie set, get and delete libray
nanocookie.min.js file size smaller than 1KB
Quick Start
Install npm package
- install nanocookie npm package
npm install nanocookie --save-dev
Import library
- Import in ECMAScript 6
import cookie from 'nanocookie';
- Import in ECMAScript 5
var cookie = require('nanocookie');
- Use from browser global
<script src="path/to/nanocookie.min.js" />
<script>
var cookie = window.nanocookie;
//...
</script>
- Get Started
cookie.set('user', 'camel'); // set cookie user:camel
cookie.get('user'); // get cookie 'camel'
cookie.delete('user'); // delete cookie
Documnet
set(name, value, exdays)
Parameters:
name
: String, cookie namevalue
: String, cookie valueexdays
: Integer, expires days(default is 1 day)
get(name)
Parameters:
name
: String, cookie name
delete(name)
Parameters:
name
: String, cookie name