Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tough-cookie

Package Overview
Dependencies
Maintainers
2
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tough-cookie

RFC6265 Cookies and Cookie Jar for node.js

  • 5.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
43M
decreased by-10.53%
Maintainers
2
Weekly downloads
 
Created

What is tough-cookie?

The tough-cookie npm package is a robust and flexible implementation of HTTP cookies, allowing for the parsing, manipulation, and serialization of cookie headers. It provides a way to manage cookies for HTTP clients, including support for persistence, cookie jars, and the ability to handle various cookie-related operations as per the RFC 6265 standard.

What are tough-cookie's main functionalities?

Cookie Parsing

This feature allows for the parsing of cookie header strings into Cookie objects, which can then be manipulated or stored.

const Cookie = require('tough-cookie').Cookie;
const cookie = Cookie.parse('key=value; expires=Wed, 09 Jun 2021 10:18:14 GMT');

Cookie Serialization

This feature enables the serialization of Cookie objects back into HTTP header strings, which can be used in HTTP requests.

const Cookie = require('tough-cookie').Cookie;
const cookie = new Cookie({key: 'value', domain: 'example.com', path: '/'});
const header = cookie.toString();

Cookie Jar

The Cookie Jar feature allows for the storage and retrieval of cookies across multiple requests, maintaining state and handling cookie scope such as domain and path.

const { CookieJar } = require('tough-cookie');
const jar = new CookieJar();
jar.setCookieSync('key=value; Domain=example.com', 'http://example.com', { http: true });

Cookie Store Persistence

This feature provides a way to persist cookies between sessions by using a file-based store or other custom store implementations.

const { CookieJar, FileCookieStore } = require('tough-cookie');
const jar = new CookieJar(new FileCookieStore('cookies.json'));
// Cookies within the jar will be persisted to 'cookies.json' file.

Other packages similar to tough-cookie

Keywords

FAQs

Package last updated on 09 Sep 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

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