js-simple-cookie
v1.1.1
Published
A simple, lightweight JavaScript API for handling cookies
Downloads
151
Readme
js-simple-cookie
A simple, lightweight JavaScript API for handling browser cookies
Features
- No dependency
- TypeScript support
Installation
NPM
npm install js-simple-cookie
CDN
Alternatively, include js-simple-cookie via jsDelivr CDN or unpkg.
Usage
Import:
import Cookies from "js-simple-cookie";
Create a cookie
Cookies.set('name', 'value')
Cookies.set({ name: 'name', value: 'value' })
Cookies.set('name', 'value', { expires: 7000 })
Cookies.set({ name: 'name', value: 'value', expires: 7000 })
Read cookie:
Cookies.get('name') // => 'value'
Cookies.get('nothing') // => undefined
Delete cookie:
Cookies.remove('name')
Cookies.remove('name', '/')
Cookies.remove('name', '/', '.yourdomain.com')