Note that there are some explanatory texts on larger screens.

plurals
  1. POExpress + Passport + Redis sessions?
    primarykey
    data
    text
    <p>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 &amp; Connect-Redis instead.</p> <p>Here is the part of my code that concerns session config with Redis:</p> <pre><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></pre> <p>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.</p> <p>For reference, here are the functions I use in passport to serialize / deserialize the session:</p> <pre><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></pre> <p>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?</p> <p>Thanks (in advance) for your help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload