Express + Passport + Redis sessions?

Darker

New Member
To date I have been using the default MemoryStore for my Express sessions. Everything has been working great, except that all session data is lost between restarts. So I am trying to get my sessions working with Redis & Connect-Redis instead.Here is the part of my code that concerns session config with Redis:\[code\]var express = require( "express" ), app = module.exports = express(), passport = require( "./passport" ), http = require( "http" ), RedisStore = require( "connect-redis" )( express ), redis = require( "redis" ).createClient();app.configure(function(){ app.set( "passport", passport ); app.use( express.cookieParser()); app.use( express.session({ secret: "I can haz working sessions?", store: new RedisStore({ client: redis }) })); app.use( passport.initialize() ); app.use( passport.session() ); ...\[/code\]When I run this application, there are no errors. However when I try to login, although it performs the initial login, I just keep getting bounced back to the login screen. It is as if passport cannot set a cookie, or cannot read a cookie after it has been set, now sessions are using the redis store. For reference, here are the functions I use in passport to serialize / deserialize the session:\[code\]passport.serializeUser(function( user, done ) { done( null, { id : user.id, type : user.type, firstname: user.firstname, lastname: user.lastname });});passport.deserializeUser(function( user, done ) { done( null, user );});\[/code\]Any advice on where I am going wrong? Do the passport serializeUser / deserializeUser need to be modified to work with redis? Or am I missing something else?Thanks (in advance) for your help.
 
Back
Top