{"id":49531,"library":"tough-cookie-web-storage-store","title":"tough-cookie-web-storage-store","description":"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.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/exponentjs/tough-cookie-web-storage-store","tags":["javascript"],"install":[{"cmd":"npm install tough-cookie-web-storage-store","lang":"bash","label":"npm"},{"cmd":"yarn add tough-cookie-web-storage-store","lang":"bash","label":"yarn"},{"cmd":"pnpm add tough-cookie-web-storage-store","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; the store implements the tough-cookie store interface.","package":"tough-cookie","optional":false}],"imports":[{"note":"Default export only; named import will fail.","wrong":"import { WebStorageCookieStore } from 'tough-cookie-web-storage-store'","symbol":"WebStorageCookieStore","correct":"import WebStorageCookieStore from 'tough-cookie-web-storage-store'"},{"note":"ESM import for tough-cookie; works with both ESM and CJS.","wrong":"const CookieJar = require('tough-cookie').CookieJar","symbol":"CookieJar","correct":"import { CookieJar } from 'tough-cookie'"},{"note":"For CommonJS, must access .default due to ESM/CJS interop.","wrong":"const WebStorageCookieStore = require('tough-cookie-web-storage-store')","symbol":"WebStorageCookieStore","correct":"const WebStorageCookieStore = require('tough-cookie-web-storage-store').default"}],"quickstart":{"code":"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'));","lang":"typescript","description":"Demonstrates creating a CookieJar with WebStorage-backed store, setting and getting a cookie synchronously."},"warnings":[{"fix":"Use jar.setCookie(cookie, url, callback) or async/await with tough-cookie's promise API.","message":"WebStorageCookieStore does not support synchronous operations; use callbacks or async methods.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Monitor storage usage, avoid storing excessive cookies, or implement custom eviction.","message":"The store uses localStorage which has a ~5MB limit in most browsers. Exceeding quota throws QuotaExceededError.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Only use this store to manage cookies, avoid tampering with internal keys.","message":"Cookies stored are serialized as JSON; do not manually modify localStorage keys with same prefix.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.0.0':21 'api':57 'back':28 'base':11 'beyond':50 'browser':38,45 'cooki':3,12,18,35,53 'cookiejar':25 'depend':49 'differenti':41 'enabl':33 'environ':39 'extra':48 'implement':27 'integr':43 'javascript':58 'key':40 'librari':19 'localstorag':30 'low':54 'mainten':55 'persist':34 'provid':23 'sessionstorag':32 'simpl':42 'stabl':56 'storag':5,10,36,46 'storage-bas':9 'store':6,13,26 'tough':2,17,52 'tough-cooki':16,51 'tough-cookie-web-storage-stor':1 'version':20 'web':4,8","created_at":"2026-06-07T17:02:14.829547+00:00","updated_at":"2026-06-07T17:02:14.829547+00:00","problems":[{"fix":"npm install tough-cookie@^2.0.0","cause":"Missing or incompatible tough-cookie version; store requires tough-cookie v2+.","error":"TypeError: store.getAllCookies is not a function"},{"fix":"Use sessionStorage or mock storage; or wrap in browser check.","cause":"Code is running in Node.js where localStorage does not exist.","error":"ReferenceError: localStorage is not defined"},{"fix":"Use const WebStorageCookieStore = require('tough-cookie-web-storage-store').default;","cause":"Using CommonJS require without .default due to ESM default export.","error":"Uncaught TypeError: Cannot read properties of undefined (reading 'default')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/exponentjs/tough-cookie-web-storage-store#readme","github":"https://github.com/exponentjs/tough-cookie-web-storage-store","docs":null,"changelog":null,"pypi":null,"npm":"tough-cookie-web-storage-store","openapi_spec":null,"status_page":null,"smithery":null,"categories":["storage"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}