biscuit.js
v1.0.7
Published
A simple JavaScript lib for handling cookies
Downloads
19
Readme
Biscuit
A simple JavaScript lib for handling cookies.
Basic Usage
Read
Read cookie:
biscuit.get('name') // => 'value'
biscuit.get('nothing') // => null
Read all visible cookie
biscuit.get() // => { name1 : 'value1', name2 : 'value2' }
Create
Create a cookie, valid across the entire site:
biscuit.set('name', 'value')
Create a cookie that expires 7 days from now, valid across the entire site:
biscuit.set('name', 'value', { expires: 7 }) // expires 7 days
Create a cookie that should be visible to a specific domain:
biscuit.set('name', 'value', { domain: 'example.com' })
Create a cookie, valid to the path of the current page:
biscuit.set('name', 'value', { path: '/'} )
Create a cookie that only be transmitted over secure protocol as https:
biscuit.set('name', 'value', { secure: true })
Remove
Remove a cookie:
biscuit.remove('name')
Remove a cookie with spcefic path or domain:
biscuit.remove('name', { path: '', domain: 'example.com'})
When deleting a cookie, you must pass the exact same path and domain attributes that was used to set the cookie.