An object containing four methods for managing cookies. The main methods set and get. And the secondary methods check and destroy.
Use npm to install bjork_cookies or copy the code manually from github.
> npm i bjork_cookie
const cookie = require('bjork_cookie')
cookie.set(key, value, opions?)
cookie.get(key, initalValue)
cookie.destroy(key)
cookie.check(key)
Format and sets the cookie according to params. Takes three parameters, key (string), value (any) and the optional options (object).
Options
- days (number): Expiration date of the cookie in days (@default 7)
- path (string): Indicates a URL path. (@default '/')
Gets the cookies value by keye. Takes two parameters, key (string) and the optional initalValue. Returns value if defined otherwise initalValue.
Info: Wrapper around get. Checks if a cookie has been set by given key. Takes one param, key. Returns Boolean.
Info: Wrapper around set, setting the expiration date to yesterday. Destroys a cookie. Takes one param, key.
Pull requests are welcome. For any considerable changes, please open an issue first to discuss what you would like to change.