Socket
Socket
Sign inDemoInstall

cookiejar

Package Overview
Dependencies
28
Maintainers
2
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    cookiejar

simple persistent cookiejar system


Version published
Weekly downloads
7.6M
decreased by-2.04%
Maintainers
2
Install size
5.69 MB
Created
Weekly downloads
 

Package description

What is cookiejar?

The npm package 'cookiejar' is a utility for handling web cookies in Node.js. It allows for the creation, retrieval, manipulation, and deletion of cookies, making it easier to manage client-side state information across web requests.

What are cookiejar's main functionalities?

Create and manage cookies

This feature allows the creation and management of cookies. The code sample demonstrates how to create a new cookie jar and set a cookie with an expiration date.

const CookieJar = require('cookiejar');
const jar = new CookieJar();
const cookie = jar.setCookie('key=value; expires=Wed, 09 Jun 2021 10:18:14 GMT');

Retrieve cookies

This feature enables the retrieval of cookies based on specific criteria such as domain and path. The code shows how to retrieve a cookie from the jar that matches the specified domain and path.

const CookieJar = require('cookiejar');
const jar = new CookieJar();
jar.setCookie('key=value; path=/; domain=example.com');
const cookie = jar.getCookie('key', {domain: 'example.com', path: '/'});

Parse and serialize cookies

This feature deals with parsing cookies from request headers and serializing them for HTTP headers. The code illustrates how to serialize all cookies in the jar for use in an HTTP request.

const CookieJar = require('cookiejar');
const CookieAccessInfo = CookieJar.CookieAccessInfo;
const jar = new CookieJar();
jar.setCookie('key=value; path=/; domain=example.com');
const serializedCookies = jar.getCookies(CookieAccessInfo.All).toValueString();

Other packages similar to cookiejar

Readme

Source

#CookieJar

Simple robust cookie library

##Exports

###CookieAccessInfo(domain,path,secure,script)

class to determine matching qualities of a cookie

#####Properties

  • String domain - domain to match
  • String path - path to match
  • Boolean secure - access is secure (ssl generally)
  • Boolean script - access is from a script

###Cookie(cookiestr_or_cookie, request_domain, request_path)

turns input into a Cookie (singleton if given a Cookie)
the `request_domain` argument is used to default the domain if it is not explicit in the cookie string 
the `request_path` argument is used to set the path if it is not explicit in a cookie String.

explicit domains/paths will cascade, implied domains/paths must *exactly* match (see http://en.wikipedia.org/wiki/HTTP_cookie#Domain_and_Pat)

#####Properties

  • String name - name of the cookie
  • String value - string associated with the cookie
  • String domain - domain to match (on a cookie a '.' at the start means a wildcard matching anything ending in the rest)
  • Boolean explicit_domain - if the domain was explicitly set via the cookie string
  • String path - base path to match (matches any path starting with this '/' is root)
  • Boolean explicit_path - if the path was explicitly set via the cookie string
  • Boolean noscript - if it should be kept from scripts
  • Boolean secure - should it only be transmitted over secure means
  • Number expiration_date - number of millis since 1970 at which this should be removed

#####Methods

  • String toString() - the set-cookie: string for this cookie
  • String toValueString() - the cookie: string for this cookie
  • Cookie parse(cookiestr, request_domain, request_path) - parses the string onto this cookie or a new one if called directly
  • Boolean matches(access_info) - returns true if the access_info allows retrieval of this cookie
  • Boolean collidesWith(cookie) - returns true if the cookies cannot exist in the same space (domain and path match)

###CookieJar()

class to hold numerous cookies from multiple domains correctly

#####Methods

  • Cookie setCookie(cookie, request_domain, request_path) - add a cookie to the jar
  • Cookie[] setCookies(cookiestr_or_list, request_domain, request_path) - add a large number of cookies to the jar
  • Cookie getCookie(cookie_name,access_info) - get a cookie with the name and access_info matching
  • Cookie[] getCookies(access_info) - grab all cookies matching this access_info

FAQs

Last updated on 20 Oct 2015

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc