Registry / storage / tough-cookie-web-storage-store

tough-cookie-web-storage-store

JSON →
library1.0.0jsnpmunverified

A Web Storage-based cookie store for the tough-cookie library, version 1.0.0. It provides a CookieJar store implementation backed by localStorage or sessionStorage, enabling persistent cookie storage in browser environments. Key differentiator: simple integration with browser storage, no extra dependencies beyond tough-cookie. Low maintenance, stable API.

npm install tough-cookie-web-storage-store
INSTALL
IMPORT
SIG · TOUGH-COOKIE-WEB-S
T
tough-cookie-web-storage-store
storagejavascriptv1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

WebStorageCookieStore
import WebStorageCookieStore from 'tough-cookie-web-storage-store'
import { WebStorageCookieStore } from 'tough-cookie-web-storage-store'
Default export only; named import will fail.
CookieJar
import { CookieJar } from 'tough-cookie'
const CookieJar = require('tough-cookie').CookieJar
ESM import for tough-cookie; works with both ESM and CJS.
WebStorageCookieStore
const WebStorageCookieStore = require('tough-cookie-web-storage-store').default
const WebStorageCookieStore = require('tough-cookie-web-storage-store')
For CommonJS, must access .default due to ESM/CJS interop.

Demonstrates creating a CookieJar with WebStorage-backed store, setting and getting a cookie synchronously.

import { CookieJar } from 'tough-cookie'; import WebStorageCookieStore from 'tough-cookie-web-storage-store'; const store = new WebStorageCookieStore(localStorage); const jar = new CookieJar(store); jar.setCookieSync('key=value', 'https://example.com'); console.log(jar.getCookieStringSync('https://example.com'));
Debug
Known issues
gotchaWebStorageCookieStore does not support synchronous operations; use callbacks or async methods.
fix
Use jar.setCookie(cookie, url, callback) or async/await with tough-cookie's promise API.
affects: >=1.0.0
gotchaThe store uses localStorage which has a ~5MB limit in most browsers. Exceeding quota throws QuotaExceededError.
fix
Monitor storage usage, avoid storing excessive cookies, or implement custom eviction.
affects: >=1.0.0
gotchaCookies stored are serialized as JSON; do not manually modify localStorage keys with same prefix.
fix
Only use this store to manage cookies, avoid tampering with internal keys.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: store.getAllCookies is not a function
Missing or incompatible tough-cookie version; store requires tough-cookie v2+.
fix
npm install tough-cookie@^2.0.0
ReferenceError: localStorage is not defined
Code is running in Node.js where localStorage does not exist.
fix
Use sessionStorage or mock storage; or wrap in browser check.
Uncaught TypeError: Cannot read properties of undefined (reading 'default')
Using CommonJS require without .default due to ESM default export.
fix
Use const WebStorageCookieStore = require('tough-cookie-web-storage-store').default;
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
tough-cookierequiredPeer dependency; the store implements the tough-cookie store interface.
Agent activity
23 hits · last 30 days
node
20
OpenAI (training)
2
Resources
tough-cookie-web-storage-store — npm install tough-cookie-web-storage-store · libregistry