Skip to content

VelociraptorCZE/Kookie

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kookie

Minuscule library for browser cookie handling with zero dependencies.

Get started

CDN

https://unpkg.com/kookie/dist/kookie.min.js

NPM

npm i kookie --save
import Kookie from "kookie";

Kookie.get("some-key");

Methods

Kookie.set(key: string, value: string, options: object): string | null

Options

  • secure: bool
  • maxAge: number
  • expires: Date
  • path: string
  • sameSite: string
  • domain: string
Kookie.set("someth]ng", "intere$ting"); // sets a cookie and returns it in a string: "someth%5Dng=in%24teresting;"
Kookie.set("temp", "42", { maxAge: 100, path: "/something" }); // sets "temp" cookie with 100 second life span

Kookie.get(key: string): string | null

Kookie.get("someth]ng"); // "in$teresting"
Kookie.get("something-not-existing"); // null

Kookie.getAll(): Map

Kookie.getAll(); // returns Map with all cookies 

Kookie.remove(key): string | null

Kookie.remove("remove-me"); // removes a cookie with key remove-me

Kookie.removeAll(): void

Kookie.removeAll(); // simply removes everything

Tests

To see tests in action, run a local server through this command:

npm run start:test

Kookie is browser oriented library, so tests are performed with a single html file on the local server.

Navigate here to see tests:

http://127.0.0.1:60061/test/

About

Minuscule library for browser cookie handling.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published