![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.