Socket
Book a DemoInstallSign in
Socket

document-cookie

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

document-cookie

Client component to set cookies

latest
Source
npmnpm
Version
0.3.0
Version published
Maintainers
0
Created
Source

A React component to set cookies in the document object.

Installation

To install the package, run:

npm install document-cookie

Usage

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;

Props

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.

License

This project is licensed under the MIT License.

FAQs

Package last updated on 28 Dec 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.