
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
document-cookie
Advanced tools
A React component to set cookies in the document object.
To install the package, run:
npm install document-cookie
Import the DocumentCookie
component and use it in your React application:
import DocumentCookie from "document-cookie";
const App = () => {
return (
<div>
<DocumentCookie
name="myCookie"
value="cookieValue"
expires={new Date("2023-12-31")}
path="/"
domain="example.com"
secure={true}
/>
</div>
);
};
export default App;
The DocumentCookie
component accepts the following props:
name
(string, required): The name of the cookie.value
(string, optional): The value of the cookie.expires
(Date, optional): The expiration date of the cookie.maxAge
(number, optional): The maximum age of the cookie in seconds.partitioned
(boolean, optional): Whether the cookie is partitioned.path
(string, optional): The path where the cookie is valid.sameSite
("strict" | "lax" | "none", optional): The SameSite attribute of the cookie.domain
(string, optional): The domain where the cookie is valid.secure
(boolean, optional): Whether the cookie should only be sent over secure protocols.This project is licensed under the MIT License.
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 Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
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.