title: Passport seems to forget the user session
body: <p>Googled for a long time, haven't really found anything that's worked so far, so figured I'd ask here.</p>
  
  <p>I'm trying to get sessions to work with Passport. I've completed the registration and login functionality, and that seems to work as it should. </p>
  
  <p>The main issue is that req.isAuthenticated always returns false.
  I've tried the usual things:</p>
  
  <p>Made sure app.use(passport.session()) comes after the express-session configuration:</p>
  
  <pre><code>... 
  app.use(logger('dev'));
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({ extended: false }));
  app.use(cookieParser());
  
  app.use(session({ 
  secret: 'somethingsomethingdarkside', 
  cookie: { maxAge: 1209600000 }, 
  saveUninitialized: false,
  resave: false,
  // using store session on MongoDB using express-session + connect
  store: new MongoStore({
      url: configDB.url,
      collection: 'sessions'
    })
  }));
  
  app.use(passport.initialize());
  app.use(passport.session()); // persistent login sessions
  ...
  </code></pre>
  
  <p>I've gone into Passports request.js file, and done some debugging, and I can see that</p>
  
  <pre><code>this[property/*user*/] = user;
  </code></pre>
  
  <p>sets the values I want it to, and that I think it should.</p>
  
  <p>Now, whenever I call </p>
  
  <pre><code>if (req.isAuthenticated())
  </code></pre>
  
  <p>it results in </p>
  
  <pre><code>this[property/*user*/] == undefined
  </code></pre>
  
  <p>returning false. I've also put in a log message telling me when the module is being initialized, and it only does it once, when the server starts.</p>
  
  <p>As far as I can see, user.deserializeUser is never called either. </p>
  
  <p>Kind of at my wits end here, anyone able to help me out?</p>