
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
cookie-management-js
Advanced tools
Package with some methods to simplify cookies management in javascript. Contains methods to add, get, delete, and update your cookies
npm i cookie-management-js
import { getItem, removeItem, setItem } from "cookie-management-js";
// Will store a cookie at the key "testKey", with the value "testValue", that will expires in 3 days, at the path "/testPath"
setItem("testKey", "testValue", 3, "/testPath");
// >> "testValue"
console.log(getItem("testKey"));
// The cookie will be cleared, and expired
deleteItem("testKey", "/testPath");
// >> ""
console.log(getItem("testKey"));
import { setItem } from "cookie-management-js";
setItem("key1", "a string expiring in 3 days at the path /path", 3, "/path");
setItem("key2", {"name": "an object expiring in 7 days at the path /"});
setItem("key3", [1, 2, 3]);
void
// Use the values stored in the example of the setItem method
import { getItem } from "cookie-management-js";
// >> "a string expiring in 3 days at the path /path"
console.log("key1")
// >> {name: "an object expiring in 7 days at the path /"}
console.log("key2")
// >> [1, 2, 3]
console.log("key3")
// >> -1
console.log("key4")
The content of the cookie, JSON parsed if possible. If no content is found at this key, return -1
// Use the values stored in the example of the setItem method
import { removeItem, getItem } from "cookie-management-js";
// >> true
console.log(removeItem("key1"));
// After remove
// >> ""
console.log(getItem("key1"));
// >> false
console.log(removeItem("key4"))
If the cookie is deleted, returns true. If the key or path is wrong, returns false
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
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.