bjork_cookie

1.2.5 • Public • Published

What is this?

An object containing four methods for managing cookies. The main methods set and get. And the secondary methods check and destroy.

Install

Use npm to install bjork_cookies or copy the code manually from github.

> npm i bjork_cookie

Usage

> const cookie = require('bjork_cookie')
>
> cookie.set(key, value, opions?)
> cookie.get(key, initalValue)
> cookie.destroy(key)
> cookie.check(key)

Set

Packages and sets a cookie according to params. Takes three parameters, key (string), value (*) and the optional options (object).

Options

  • days (number): Expiration date of the cookie in days (@default 7)
  • path (string): Indicates a URL path. (@default '/')

Get

Fetches cookie by key and extracts value. Takes two parameters, key (string) and the optional initalValue. Returns value | initalValue.

Check

Checks if a cookie by the given key exists. Takes one param, key. Returns Boolean. Utilizes get.

Destroy

Destroys a cookie by overwriting it. Takes one param, key. Utilizes set and an expiration date of yesterday.

Contribution

Pull requests are welcome. For any considerable changes, please open an issue first to discuss what you would like to change.

Licence

MIT

Package Sidebar

Install

npm i bjork_cookie

Weekly Downloads

15

Version

1.2.5

License

MIT

Unpacked Size

5.55 kB

Total Files

4

Last publish

Collaborators

  • emileinarsen