New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cookie-muncher

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cookie-muncher

Effortless cookie management

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
139
decreased by-0.71%
Maintainers
1
Weekly downloads
 
Created
Source

A lightweight and typesafe package for manipulating cookies in Node.js and the browser.

Installation

You can install Cookie Muncher via NPM, Yarn or PNPM.

npm install cookie-muncher
yarn add cookie-muncher
pnpm install cookie-muncher

Usage

Serialize a cookie into a string.

import type { Cookie, CookieOptions } from "cookie-muncher";
import { serializeCookie, CookieMaxAge } from "cookie-muncher";

const cookie: Cookie = {
  name: "myCookie",
  value: "myValue",
};

const options: CookieOptions = {
  maxAge: CookieMaxAge.TwoWeeks,
  path: "/",
  secure: true,
  sameSite: "Strict",
};

const serializedCookie = serializeCookie(cookie, options);

console.log(serializedCookie);
// "myCookie=myValue; Max-Age=3600; Path=/; Secure; SameSite=Strict"

Parse a string of cookies into an array of cookie objects.

import { parseCookies } from "cookie-muncher";

const cookies = "myCookie1=myValue1; myCookie2=myValue2";

const parsedCookies = parseCookies(cookies);

console.log(parsedCookies); 
// [{ name: "myCookie1", value: "myValue1" }, { name: "myCookie2", value: "myValue2" }]

License

This package is MIT licensed.

FAQs

Package last updated on 23 Apr 2023

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc