zax-cookie
v1.0.10
Published
js cookie
Downloads
9
Readme
Zax-cookie ·
Cookie module
Browsers support
| IE / Edge | Firefox | Chrome | Safari | iOS Safari | Opera | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | IE8+ Edge+ | last 10 versions | last 10 versions | last 2 versions | last 2 versions | last 2 versions |
Install
npm i zax-cookie -S
or
yarn add zax-cookie
Usage
import zaxCookie, { getDomain, setCookie, getCookie, delCookie, clearCookie } from 'zax-cookie'
or
const zaxCookie, { getDomain, setCookie, getCookie, delCookie, clearCookie } = require('zax-cookie')
. getDomain
zaxCookie.getDomain() //=> getDomain()
localhost
. set
zaxCookie.set('token', 'abc') //=> setCookie('token', 'abc')
zaxCookie.set('token', 'abc', 1)
zaxCookie.set('token', 'abc', {
path: '/',
domain: 'demo.com'
expires: new Date(Date.now() + 1 * 864e5),
sameSite: 'lax'
})
token=abc; path=/; domain=localhost
token=abc; path=/; domain=localhost; expires=Wed, 20 Nov 2019 09:18:38 GMT
token=abc; path=/; domain=demo.com; expires=Wed, 20 Nov 2019 09:18:38 GMT; sameSite=lax
. get
zaxCookie.get('token') //=> getCookie('token')
abc
. del
zaxCookie.del('token') //=> delCookie('token')
zaxCookie.del('token', {
path: '/',
domain: 'demo.com'
})
. clear
zaxCookie.clear() //=> clearCookie()