Socket
Socket
Sign inDemoInstall

ssr-cookie

Package Overview
Dependencies
1
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ssr-cookie

Facade for server and client side cookies.


Version published
Weekly downloads
928
increased by887.23%
Maintainers
1
Install size
30.6 kB
Created
Weekly downloads
 

Readme

Source

ssr-cookie implements a convenience common interface to access cookies in applications with server-side rendering (SSR).

Installation

NPM
  $ npm install ssr-cookie --save
Yarn
  $ yarn add ssr-cookie

Basic Usage

On the server

It requires Express and cookie-parser middleware.

import SsrCookie from "ssr-cookie";
const cookie = new SsrCookie(req, res);

// Set cookie
cookie.set("user", {userName: "test", token: "some token here"});

// Retrieve cookie
const user = cookie.get("user");

// Clear cookies
cookie.remove("user");

On the client

It uses js-cookie to access cookies on a client.

import SsrCookie from "ssr-cookie";
const cookie = new SsrCookie();

// Set cookie
cookie.set("user", {userName: "test", token: "some token here"}, { expires: 30 });

// Retrieve cookie
const user = cookie.get("user");

// Clear cookies
cookie.remove("user");

Authors

  • Alexander Fedorenko

Keywords

FAQs

Last updated on 23 Sep 2019

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc