title: Using cookieSession with Passport
body: <p>I want to use cookie session store with Passport because memory store is not designed for production:</p>
  
  <pre><code>Warning: connection.session() MemoryStore is not
  designed for a production environment, as it will leak
  memory, and will not scale past a single process.
  </code></pre>
  
  <p>Here's my Express initialization:</p>
  
  <pre><code>app.use(express.bodyParser({keepExtensions:true}));
  app.use(express.cookieParser(cookieSecret));
  app.use(express.cookieSession({ 
      key: cookieKey,
      secret: cookieSecret,
      maxAge: sessionTimeout
  }));
  app.use(passport.initialize());
  app.use(passport.session());
  app.use(express.methodOverride());
  app.use(express.static(__dirname + '/public'));
  </code></pre>
  
  <p>Everything works normally if I change <code>express.cookieSession</code> to <code>express.session</code>. When using <code>cookieSession</code> user login succeeds but the user is not logged in anymore after next page load occurs. Any tips how to make passport work with cookie sessions?</p>
  
  <p>I'm using Express 3.0.0</p>