0.1.0 • Published 5 years ago
esm-cookie v0.1.0
JavaScript Module Cookie
ES Module version of the cookie package
Example for how to load the ES module in a browser:
<script type="module" src="cookie.js"></script>
OR
<script type="module">
import cookie from 'cookie.js'
</script>
Basic Usage
Create a cookie, valid across the entire site:
cookie.set('name', 'value')
Create a cookie that expires 7 days from now, valid across the entire site:
cookie.set('name', 'value', { expires: 7 })
Create an expiring cookie, valid to the path of the current page:
cookie.set('test', 'value_test', { expires: 7, path: '' })
Read cookie:
cookie.get('name') // => 'value'
cookie.get('nothing') // => undefined
Read all visible cookies:
cookie.getAll() // => { name: 'value', test: 'value_test' }
Check if cookie exist
cookie.check("name") // => true
0.1.0
5 years ago