title: Node Passport session lost on subsequent calls
body: <p><strong>I believe I have configured everything correctly:</strong></p>
  
  <pre><code>app.configure(function() {
      app.use(express.cookieParser('secret message')); // secret it set here in new version of express or connect
      app.use(express.bodyParser());
      app.use(express.session());
      app.use(passport.initialize());
      app.use(passport.session());
  });
  </code></pre>
  
  <p>When the request is made to "login" <strong>with the correct credentials:</strong></p>
  
  <pre><code>app.post('/api/login', passport.authenticate('local'), function (req, res, next) {
      console.log(req.session.passport);  // {"user":"5259f2739d4323000a000003"}
  });
  </code></pre>
  
  <p><code>req.session.passport</code> is populated:</p>
  
  <pre><code>"passport": {"user":"5259f2739d4323000a000003"}
  </code></pre>
  
  <p>However, when a call is made to:</p>
  
  <pre><code>app.post('/api/checklogin', function (req, res, next) {
      console.log(req.session.passport);  // {}
  })
  </code></pre>
  
  <p><code>req.session.passport</code> is lost:</p>
  
  <pre><code>"passport":{}
  </code></pre>
  
  <p>Both times, <code>req.session</code> looks like this:</p>
  
  <pre><code>{"cookie":{"originalMaxAge":null,"expires":null,"httpOnly":true,"path":"/"},"passport":{}}
  </code></pre>
  
  <p>** Passport object is obviously different though, as described above</p>
  
  <p>I assume I have configured <code>serializeUser</code> correctly, because it correctly sets this property.</p>
  
  <p>I am not completely sure how Passport creates session cookies, and how these cookies can persist.</p>
  
  <p>I assume that <code>req.session.passport</code> is supposed to retain the user property, but it seems that the Passport object either: </p>
  
  <ol>
  <li>Resets on every call </li>
  <li>Does not actually save the Passport property in the session</li>
  <li>The session is never created</li>
  </ol>
  
  <p>I fear that I may be overlooking something large -- possibly something that I may need to do that Passport doesn't handle directly for me.</p>
  
  <p>I do not know of any way to test if the session is created by Passport.</p>
  
  <p>Any advice or help is really appreciated. This has been a multiple day struggle.</p>