@0x44ru5h/cookie-jar

1.0.0 • Public • Published

Cookie Jar v0.0.1

a small api for cookies

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.

Readme

Keywords

none

Package Sidebar

Install

npm i @0x44ru5h/cookie-jar

Weekly Downloads

1

Version

1.0.0

License

AGPL-3.0-or-later

Unpacked Size

37.9 kB

Total Files

7

Last publish

Collaborators

  • 0x44ru5h