You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

cookies-utils

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cookies-utils

A JavaScript API for handling cookies

1.0.0
latest
Source
npmnpm
Version published
Weekly downloads
27
-59.09%
Maintainers
1
Weekly downloads
 
Created
Source

cookies-utils

NPM Version Build Status

This project contains functions to help manage cookies.

Installation

NPM

Install the library with npm install cookies-utils.

CDN

Or use it directly in your browser via jsDelivr or unpkg:

<script src="https://cdn.jsdelivr.net/npm/cookies-utils/cookies-utils.min.js"></script>

...

cookiesUtils.deleteCookie('name')

or

<script src="https://unpkg.com/cookies-utils/cookies-utils.min.js"></script>

...

cookiesUtils.deleteCookie('name')

Usage

Set a cookie

import { setCookie } from "cookies-utils";

// more information about the options in documentation https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie
const cookieOptions = {
  name: "name", // string,
  value: "value", // string,
  maxAge: 10 * 60, // optional number (value in seconds),
  expires: new Date(2099, 10, 1), // optional Date,
  path: "/path", // optional string,
  domain: "site.com", // optional string,
  secure: true, // optional boolean,
  sameSite: "lax", // optional enum 'lax' | 'strict' | 'none'
};
setCookie(cookieOptions);

Check existence of cookie

import { cookieExists } from "cookies-utils";

const isExist = cookieExists("name");

Delete a cookie

import { deleteCookie } from "cookies-utils";

deleteCookie("name");

Check if cookie has specific value

import { cookieHasValue } from "cookies-utils";

const hasValue = cookieHasValue("name", "value");

Delete all cookies

import { deleteAllCookies } from "cookies-utils";

deleteAllCookies();

Keywords

cookie

FAQs

Package last updated on 07 Nov 2020

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.