Cookies.js is a lightweight client-side JavaScript library for managing browser cookies, adhering to RFC6265 standards. The current stable version is 1.2.3, which was released approximately eight years ago (as of April 2026), indicating that the project is likely abandoned or in a deep maintenance phase with no active development. It distinguishes itself by having no external dependencies, offering cross-browser compatibility (IE6+, Chrome, Firefox 3+, Safari 4+, Opera 10+), and being released into the public domain. The library supports AMD and CommonJS module loaders and includes specific provisions for use in Node.js environments that lack a native `window` object, requiring a factory method for initialization. It transparently handles URI encoding of cookie keys and values using UTF-8 representation.
npm install cookies-jsVerified import paths — ran on the pinned version, not inferred.
Demonstrates setting, getting, and expiring cookies using Cookies.js within a Node.js environment by simulating a browser's `window` object with `jsdom`.
For new projects, consider more actively maintained cookie management libraries. For existing projects, be aware of the lack of ongoing support and potential future compatibility issues or unpatched vulnerabilities.
Review the licensing terms if your project's legal compliance depends on the pre-1.0.0 licensing model. The API itself remained stable from 0.4.0, so code changes are generally not required.
For Node.js, use a library like `jsdom` to create a `window` instance and pass it to the `cookies-js` factory: `const { JSDOM } = require('jsdom'); const window = new JSDOM().window; const Cookies = require('cookies-js')(window);`Ensure all cookie keys and values are consistently URI encoded using UTF-8. For .NET users, specifically avoid `HttpUtility.UrlEncode` and `HttpUtility.UrlDecode`, and instead use `System.Uri.EscapeDataString` and `System.Uri.UnescapeDataString`.
Upgrade `cookies-js` to version `1.2.3` or higher to resolve issues related to global context availability in modern bundling environments.
Initialize `cookies-js` by providing a `window` instance from a library like `jsdom`: `const { JSDOM } = require('jsdom'); const window = new JSDOM().window; const Cookies = require('cookies-js')(window);`Verify that both client and server are using compatible URI encoding (UTF-8). For .NET, use `System.Uri.EscapeDataString` and `System.Uri.UnescapeDataString` instead of `HttpUtility` methods.
Upgrade `cookies-js` to version `0.4.0` or higher to fix the `Cookies.enabled` detection in IE7/IE8.
No dependency data recorded yet.