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

@postman/tough-cookie

Package Overview
Dependencies
Maintainers
371
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@postman/tough-cookie

RFC6265 Cookies and Cookie Jar for node.js

  • 4.1.3-postman.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
821K
decreased by-1.59%
Maintainers
371
Weekly downloads
 
Created

What is @postman/tough-cookie?

@postman/tough-cookie is a robust, standards-compliant cookie library for Node.js. It allows you to manage cookies in a way that adheres to the RFC 6265 specification, making it useful for handling HTTP cookies in web scraping, testing, and other HTTP client scenarios.

What are @postman/tough-cookie's main functionalities?

Cookie Creation

This feature allows you to create and parse cookies from a string. The code sample demonstrates how to parse a cookie string into a Cookie object.

const { Cookie } = require('@postman/tough-cookie');
const cookie = Cookie.parse('SID=31d4d96e407aad42; Path=/; Domain=example.com');
console.log(cookie);

Cookie Jar

The Cookie Jar feature allows you to store and manage multiple cookies. The code sample shows how to create a Cookie Jar, add a cookie to it, and retrieve cookies for a specific URL.

const { CookieJar } = require('@postman/tough-cookie');
const jar = new CookieJar();
jar.setCookieSync('SID=31d4d96e407aad42; Path=/; Domain=example.com', 'http://example.com');
console.log(jar.getCookiesSync('http://example.com'));

Cookie Serialization

This feature allows you to serialize a Cookie object back into a string. The code sample demonstrates how to convert a Cookie object into a string format.

const { Cookie } = require('@postman/tough-cookie');
const cookie = Cookie.parse('SID=31d4d96e407aad42; Path=/; Domain=example.com');
const serialized = cookie.toString();
console.log(serialized);

Cookie Expiration

This feature allows you to handle cookie expiration. The code sample shows how to parse a cookie with an expiration date and check its expiry time.

const { Cookie } = require('@postman/tough-cookie');
const cookie = Cookie.parse('SID=31d4d96e407aad42; Path=/; Domain=example.com; Expires=Wed, 09 Jun 2021 10:18:14 GMT');
console.log(cookie.expiryTime(new Date()));

Other packages similar to @postman/tough-cookie

Keywords

FAQs

Package last updated on 07 Jun 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