I would like to set a sessionStore with Redis (to use with passport.socketio) anybody can point me in the right direction? I am using express@3.2.6 and connect-redis@1.4.7
I can set the sessionStore as a MemoryStore, and as a MongoStore, but cannot figure out how to do it with Redis
Using MemoryStore
var express = require('express');
var sessionStore = new express.session.MemoryStore();
Using MongoStore
var express = require('express');
var mongoose = require('mongoose');
var MongoStore = require('connect-mongo')(express);
mongoose.connect("mongodb://mydatabase_uri")
var db = mongoose.connection
var sessionStore = new MongoStore({mongoose_connection: db});
Using RedisStore <---- EDIT: this works after installing redis---->
var express = require('express');
var RedisStore = require('connect-redis')(express);
var sessionStore = new RedisStore();
=================================================================================
Redis Store
var session = require('express-session');
var RedisStore = require('connect-redis')(session);
var sessionStore = new RedisStore(options);
app.use(session({
store: sessionStore,
secret: 'keyboard cat'
}));
To use the RedisStore one needs first to install redis and start the redis-server. This is how to do it on ubuntu,
To install:
To restart the redis-server