Reputation: 7191
app.use(express.session({
store: new RedisStore({
host: 'localhost',
port: 6379,
db: 0,
pass: 'RedisPASS'
}),
secret: '1234567890QWERTY'
}));
The above creates a session store in Redis. But the entry of session data is in some random key like sess:0t-8-qJG5s0e3w4oGhBjxgAH
. What is best way to get the key of the session established?
Upvotes: 0
Views: 819
Reputation: 203419
This should do the trick:
var key = req.sessionStore.prefix + req.sessionID;
(obviously you need to run this code in a middleware or a route handler)
Upvotes: 1
Reputation: 34337
If you want to use a different prefix than sess
do it like this:
app.use(express.session({
store: new RedisStore({
host: 'localhost',
port: 6379,
db: 0,
pass: 'RedisPASS',
prefix: 'mycustomprefix'
}),
secret: '1234567890QWERTY'
}));
Upvotes: 1