Express-Redis-Session
This is a node Express middleware to store session into redis.
Install with:
$npm install node-redis-session
Usage
var express = ;var cookieParser = ;var redisSession = ;var app = ; app;app; app; app;
Session will be store in redis, as JSON.stringify(req.session). You can find it with redis command line.
redisSession(options)
Other way to establish a redisSession is:
var express = ;var cookieParser = ;var redisSession = ;var app = ; app;app;
So cookie-name in browser will be set as mySessionid
. It's useful when multi projects are use redisSession. Do this and escape projects from use same cookie-name.
Options
redisOptions
: configure redis, must be a array. ex:[6379, 'localhost', {auth_pass: 'auth_pass'}]
redisClient
: redis client, if exists ignore redisOptions.cookieName
: overwrite default cookie name, useful in multi products.expireTime
: cookie expire time in browser / session expire time in redis. count with ms.cacheCookieName
: multi application use sso will hold same session. and use this to hold a cache in single app. usage:req.cache
.cookieOptions
: see third param in http://expressjs.com/zh-cn/api.html (search res.cookie). // Object.assign({expires, httpOnly}, cookieOptions);
Contributors
Run test
$npm test