Skip to content

Ghasty003/Lazy-Cookie

Repository files navigation

Lazy-Cookie

Easy to use JavaScript/TypeScript library that makes working with cookies on client side less of a pain.

Installation

npm i lazycookie

Usage

It has same methods as localStorage & sessionStorage

import cookie from "lazycookie";

cookie.getItem("foo") // returns a string which is the value of the provided parameter.

cookie.setItem("foo", "bar", options) // sets item with key of "foo" and value of "bar".

cookie.deleteItem("foo") // deletes item with key of "foo".

cookie.clear()  // clears all key/value pairs.

cookie.length // returns the total number of key/value pair.

Optional parameters

Name Value Description
expires Date When cookie should expire in Date format.
maxAge number When cookie should expire in millisecond.

Releases

No releases published

Packages

No packages published