$ git clone https://github.com/geemo/redis-session.git
const app = express();
const session = require('redis-session');
app.use(session({
url: 'redis://127.0.0.1:6379/0',
sidKey: 'redis.sid',
cookie: {
maxAge: 24 * 60 * 60 * 1000 //ms
},
ttl: 24 * 60 * 60, //sec
resave: true,
saveUninit: false
}));
Create a session middleware with the given options
.
Redis server url. The default value is "redis://127.0.0.1:6379/0".
Session ID cookie name. The default value is "redis.sid".
Settings for the session ID cookie.
The default value is { path: '/', httpOnly: true, maxAge: 604800000 \*7 days*\}
.
Redis session TTL (expiration) in seconds. The default value is one day.
Forces the session to be saved back to the session store. The default value is true.
Forces a session that is "uninitialized" to be saved to the store. The default value is true.