Registry / storage / node-redis-session

node-redis-session

JSON →
library0.3.4jsnpmunverified

Express middleware for storing sessions in Redis. Current stable version 0.3.4, last updated in 2016 with no recent releases. Maintains session data as JSON in Redis, supports custom cookie names, expiration, and existing Redis clients. Lightweight alternative to connect-redis, but lacks TypeScript definitions and modern maintenance.

npm install node-redis-session
INSTALL
IMPORT
SIG · NODE-REDIS-SESSION
N
node-redis-session
storagejavascriptv0.3.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
const redisSession = require('node-redis-session');
import redisSession from 'node-redis-session';
CommonJS only; no ESM support.
redisSession
const redisSession = require('node-redis-session'); app.use(redisSession());
const { redisSession } = require('node-redis-session');
Default export, not named.
options
const redisSession = require('node-redis-session'); app.use(redisSession({ expireTime: 60000 }));
app.use(redisSession(redisClient));
Options object required, not direct client.

Basic Express app using node-redis-session with default Redis connection on localhost:6379.

const express = require('express'); const cookieParser = require('cookie-parser'); const redisSession = require('node-redis-session'); const app = express(); app.use(cookieParser()); app.use(redisSession()); app.get('/', function(req, res) { if (!req.session.user) { req.session.user = { name: 'anonymous' }; } res.end('hello '+req.session.user.name); }); app.listen(3000);
Debug
Known issues
gotcharedisSession() must be called after cookieParser() middleware.
fix
Ensure cookieParser is used before redisSession.
affects: all
gotchaIf no redisClient is provided, the library uses redis.createClient(6379, 'localhost') by default. This may fail if Redis is not on localhost or uses authentication.
fix
Pass redisClient option: redisSession({ redisClient: myClient })
affects: all
deprecatedCookie options for httpOnly and secure may need explicit setting for production.
fix
Set cookieOptions: { httpOnly: true, secure: true } when using HTTPS.
affects: all
Errors
Common errors & fixes
Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED
Redis server not running or not accessible.
fix
Start Redis server or specify correct redisOptions: redisSession({ redisOptions: [6379, 'your-host', { auth_pass: 'password' }] })
Cannot read property 'session' of undefined
req.session is undefined because cookie-parser or redisSession middleware not applied before route handler.
fix
App.use cookieParser() and redisSession() before defining routes.
Upgrade
Version history
0.3.4latest on npm
Audit
Dependencies
redisrequiredRedis client for session storage
cookie-parserrequiredRequired express middleware for cookie parsing
Agent activity
29 hits · last 30 days
node
28
Amazon
1
Resources
node-redis-session — npm install node-redis-session · libregistry