
Product
Introducing Reports: An Extensible Reporting Framework for Socket Data
Explore exportable charts for vulnerabilities, dependencies, and usage with Reports, Socket’s new extensible reporting framework.
universal-cookie
Advanced tools
Universal cookies for JavaScript
react-cookie - Universal cookies for Reactuniversal-cookie-express - Hook cookies get/set on Express for server-renderingnpm install universal-cookie
or in the browser (global variable UniversalCookie):
<script
crossorigin
src="https://unpkg.com/universal-cookie@7/umd/universalCookie.min.js"
></script>
constructor([cookieHeader], [defaultSetOptions])Create a cookies context
/ as the path if you want your cookie to be accessible on all pagesget(name, [options])Get a cookie value
getAll([options])Get all cookies
set(name, value, [options])Set a cookie value
/ as the path if you want your cookie to be accessible on all pagesremove(name, [options])Remove a cookie
/ as the path if you want your cookie to be accessible on all pagesaddChangeListener(callback)Add a listener to when a cookie is set or removed.
name, value and options of the changed cookie.removeChangeListener(callback)Remove a listener from the change callback.
removeAllChangeListeners()Remove all change listeners that were previously added with addChangeListener().
update()Read back the cookies from the browser and triggers the change listeners. This should normally not be necessary because this library detects cookie changes automatically.
import Cookies from 'universal-cookie';
const cookies = new Cookies(null, { path: '/' });
cookies.set('myCat', 'Pacman');
console.log(cookies.get('myCat')); // Pacman
import Cookies from 'universal-cookie';
const cookies = new Cookies(req.headers.cookie, { path: '/' });
console.log(cookies.get('myCat')); // Pacman or undefined if not set yet
js-cookie is a simple, lightweight JavaScript API for handling cookies. It provides a straightforward way to create, read, and delete cookies on the client-side. Compared to universal-cookie, js-cookie is specifically designed for browser environments and does not support server-side rendering.
cookie is a Node.js module for parsing and serializing cookies. It's designed for server-side use, allowing for easy manipulation of HTTP cookies in Node.js applications. Unlike universal-cookie, cookie does not provide a unified API for both client and server environments.
cookies is a Node.js and browser module that provides a higher-level API for managing cookies in both environments. It offers features similar to universal-cookie but with additional options for security, such as automatic signing of cookies. It's a good alternative for applications requiring enhanced security measures.
FAQs
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.

Product
Explore exportable charts for vulnerabilities, dependencies, and usage with Reports, Socket’s new extensible reporting framework.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.