Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
electrode-cookies
Advanced tools
Electrode isomorphic cookies lib.
npm install electrode-cookies --save
This module offers reading and setting cookies in React code that works in both the browser or when doing Server Side Rendering.
In your pure server only code, you can also use this module to read and set cookies, but you MUST pass the request
object in the options. Otherwise an assert error will be thrown.
In NodeJS land:
const Cookies = require("electrode-cookies");
In ReactJS land:
import Cookies from "electrode-cookies";
const value = Cookies.get("test-cookie");
In NodeJS land:
Note the difference is that
request
is passed in options.
const Cookies = require("electrode-cookies");
const value = Cookies.get("test-cookie", { request });
In ReactJS land:
import Cookies from "electrode-cookies";
Cookies.set( "foo", "bar", { path: "/", domain: ".walmart.com" } );
In NodeJS land:
Note the difference is that
request
is passed in options.
const Cookies = require("electrode-cookies");
Cookies.set( "foo", "bar", { request, path: "/", domain: ".walmart.com" } );
The cookie writing on server side requires support from a Hapi plugin. If you use electrode-server, then it should have setup the plugin for you by default. Otherwise, you need to register the hapi plugin.
Cookies.get(key, [options])
Parameters:
key
- name of the cookieoptions
- (optional) Available for Server side only. options for getting the cookie
request
- The server request
object (Required on server).matchSubStr
- If true
, then do substring matching of key with all cookie keys.
skipEncoding
- (applies only if matchSubStr
is true
) If true
, then do not encode the key or decode the value.Returns the value of the cookie for key
.
Cookies.set(key, value, [options])
Set a cookie with key
and value
.
Parameters:
key
- name of the cookievalue
- value of the cookieoptions
- (optional) options for the cookie
request
- On the server side, the request
object (Required on server).path
- string path of the cookie Default: "/"
domain
- string domain of the cookieexpires
- number of seconds the cookie will expiresecure
- A boolean of whether or not the cookie should only be available over SSL Default: falsehttpOnly
- A boolean of whether or not the cookie should only be available over HTTP(S) Default: falseforceAuthEncoding
- Forces non-standard encoding for +
and /
characters, use with auth cookies.skipEncoding
- Skip encoding/escaping of the cookie value. See source for details.Cookies.expire(key, [options])
Expires a cookie specified by key
.
Parameters:
key
- name of the cookieoptions
- (optional) options for the cookie
path
- string path of the cookie Default: "/"
domain
- string domain of the cookiesecure
- A boolean of whether or not the cookie should only be available over SSL Default: falserequest
- The server request object (Required on server)FAQs
Electrode ISO cookies lib
We found that electrode-cookies demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.