# cookiejar

> simple persistent cookiejar system

Latest version **2.1.4** (published 2023-01-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install cookiejar
pnpm add cookiejar
yarn add cookiejar
bun add cookiejar
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.4 |
| Published | 2023-01-13 |
| First published | 2011-03-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/cookiejar) |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 14.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 122 |
| Author | bradleymeck |
| Maintainers | andyburke, bradleymeck |

## Links

- npm: https://www.npmjs.com/package/cookiejar
- Repository: https://github.com/bmeck/node-cookiejar
- Homepage: https://github.com/bmeck/node-cookiejar#readme
- Issues: https://github.com/bmeck/node-cookiejar/issues
- npm.io page: https://npm.io/package/cookiejar

## Recent versions

- 2.1.4 (latest) — 2023-01-13
- 2.1.3 — 2021-09-29
- 2.1.2 — 2018-05-30
- 2.1.1 — 2017-04-05
- 2.1.0 — 2016-07-13
- 2.0.6 — 2015-11-11
- 2.0.4 — 2015-10-20
- 2.0.3 — 2015-09-14
- 2.0.2 — 2015-09-08
- 2.0.1 — 2014-07-03
- 2.0.0 — 2014-06-19
- 1.3.2 — 2014-04-22
- 1.3.1 — 2014-02-20
- 1.3.0 — 2011-05-24
- 1.0.0 — 2011-03-28
- … 5 more at https://npm.io/package/cookiejar/versions

## README

# CookieJar

[![NPM version](http://img.shields.io/npm/v/cookiejar.svg)](https://www.npmjs.org/package/cookiejar)
[![devDependency Status](https://david-dm.org/bmeck/node-cookiejar/dev-status.svg)](https://david-dm.org/bmeck/node-cookiejar?type=dev)

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)

It 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)` - modify (or add if not already-existing) a cookie to the jar
* `Cookie[] setCookies(cookiestr_or_list, request_domain, request_path)` - modify (or add if not already-existing) 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

---
_Source: https://npm.io/package/cookiejar · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
