@zaxjs/cookie
v0.0.3
Published
js cookie
Downloads
5
Maintainers
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 @zaxjs/cookie -S
build with rollup
npm run build
use
import zaxCookie, { getDomain, setCookie, getCookie, delCookie, clearCookie } from '@zaxjs/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()