3 points

Memcached Cloud session store with express-session to preserve sessions off-server


Fri May 08 2020 23:05:13 GMT+0000 (UTC)

Posted by @mishka #nodejs

var express = require("express");
var app = express();
const session = require('express-session');
var MemcachedStore = require('connect-memjs')(session);

// configure sessions
var store = new MemcachedStore({servers: [process.env.MEMCACHEDCLOUD_SERVERS], username: process.env.MEMCACHEDCLOUD_USERNAME, password: process.env.MEMCACHEDCLOUD_PASSWORD});
app.use(session({ secret: 'keyboard cat',
   resave: true,
   saveUninitialized: true,
   cookie: { secure: true }, 
   store: store
content_copy Copy

Connect-memjs: https://www.npmjs.com/package/connect-memjs Memcached Cloud: https://redislabs.com/lp/memcached-cloud/