1.0.0 • Published 3 years ago

@0x44ru5h/cookie-jar v1.0.0

Weekly downloads
-
License
AGPL-3.0-or-later
Repository
github
Last release
3 years ago

Overview

cookie-jar is a minimal javascript library that allows developers to access and use cookies quickly, simply, and efficiently.

API

set(name, value)

Create a cookie

jar.set("username", "aarushgupta")

The code above creates a cookie with name username and value aarushgupta.

get(name)

Get the value of a cookie

jar.get("username")

The code above returns aarushgupta, the value set of username.

update(name, new)

Update the value of a cookie

jar.set("username", "theaarushgupta")

The code updates username and changes its value to theaarushgupta.

remove(name)

Removes a cookie

jar.remove("username")

The code above removes the cookie username.

Examples

Basic Usage

let jar = new Jar()

jar.set("username", "aarushgupta")
console.log(jar.get("username"))

jar.update("username", "theaarushgupta")
console.log(jar.get("username"))

jar.remove("username")

This code sets a cookie, gets its value, updates it, and then removes it, showing the simplicity of the REST-like Jar class.

Console output

aarushgupta
theaarushgupta

Browser Compatibility

cookie-jar works in all modern browsers, both desktop and mobile.

Copyright © 2021 Aarush Gupta

This code is copyrighted but licensed to the public under the GNU AGPLv3 license and any later versions.