npm.io
0.1.0 • Published 7 years ago

esm-cookie

Licence
—
Version
0.1.0
Deps
0
Size
3 kB
Vulns
0
Weekly
0

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

Keywords