title: Node.js - Session doesn't persist through res.redirect()
body: <p>I'm (almost) successfully using Node.js with Express and Redis to handle sessions.</p>
  
  <p>The problem I'm having is that the session is not kept when I use <code>res.redirect()</code>.</p>
  
  <p>Here is how I can see it :</p>
  
  <pre><code>req.session.username = username.toString();
  console.log(req.session);
  res.redirect('/home');
  </code></pre>
  
  <p>The console.log() prints :</p>
  
  <pre><code>{ lastAccess: 1322579131762,
    cookie:
     { path: '/',
       httpOnly: true,
       _expires: Tue, 29 Nov 2011 15:06:31 GMT,
       originalMaxAge: 60000 },
    username: 'admin' }
  </code></pre>
  
  <p>Now, here is the following code :</p>
  
  <pre><code>app.get('/home', [app.requireLogin], function(req, res, next) {
  // Not showing the rest as it's not even getting there
  // Instead, here is what's interesting
  app.requireLogin = function(req, res, next) {
    console.log(req.session);
  </code></pre>
  
  <p>This console.log() prints out this :</p>
  
  <pre><code>{ lastAccess: 1322579131775,
    cookie:
     { path: '/',
       httpOnly: true,
       _expires: Tue, 29 Nov 2011 15:06:31 GMT,
       originalMaxAge: 60000 } }
  </code></pre>
  
  <p>Clearly, the 'username' object has disappeared. The session has not kept it, and just rebuilt a new one.</p>
  
  <p>How can I solve this? Don't hesitate if you need any information.</p>
  
  <p>Here is the code where I set the session management :</p>
  
  <pre><code>app.configure(function() {
    // Defines the view folder and engine used.
    this.set('views', path.join(__dirname, 'views'));
    this.set('view engine', 'ejs');
  
    // Allow parsing form data
    this.use(express.bodyParser());
  
    // Allow parsing cookies from request headers
    this.use(express.cookieParser());
    // Session management
    this.use(express.session({
      // Private crypting key
      secret: 'keyboard cat',
      store: new RedisStore,
      cookie: {
        maxAge: 60000
      }
    }));
    this.use(app.router);
  });
  </code></pre>
  
  <p>Here is the whole project (I mean, parts of it), on gist : <a href="https://gist.github.com/c8ed0f2cc858942c4c3b">https://gist.github.com/c8ed0f2cc858942c4c3b</a> (ignore the properties of the rendered views)</p>