🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

js-simple-cookie

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-simple-cookie

A simple, lightweight JavaScript API for handling cookies

Source
npmnpm
Version
1.2.0
Version published
Weekly downloads
19
-53.66%
Maintainers
1
Weekly downloads
 
Created
Source

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

Read all visible cookies:

Cookies.get() // => { name: 'value' }

Delete cookie:

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

Keywords

cookie

FAQs

Package last updated on 26 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts