npm

js-simple-cookie
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

js-simple-cookie

A simple, lightweight JavaScript API for handling browser cookies

Features

  • No dependency
  • TypeScript support

Installation

NPM

npm install js-simple-cookie

CDN

Alternatively, include js-simple-cookie via jsDelivr CDN or unpkg.

Usage

Import:

import Cookies from "js-simple-cookie";

Create a cookie

Cookies.set('name', 'value')
Cookies.set({ name: 'name', value: 'value' })
Cookies.set('name', 'value', { expires: 7000 })
Cookies.set({ name: 'name', value: 'value', expires: 7000 })

Read cookie:

Cookies.get('name') // => 'value'
Cookies.get('nothing') // => undefined

Delete cookie:

Cookies.remove('name')
Cookies.remove('name', '/')
Cookies.remove('name', '/', '.yourdomain.com')

Package Sidebar

Install

npm i js-simple-cookie

Weekly Downloads

107

Version

1.1.1

License

MIT

Unpacked Size

23.7 kB

Total Files

11

Last publish

Collaborators

  • lxf2513