title: node.js + express.js: session handling with mongodb/mongoose
body: <p>Right now i'm storing my session data in the "memory store" which comes bundled with connect(express). But I want/have to change this for production.</p>
  
  <p>The application is using mongodb and I installed mongoose to handle all db-communications.</p>
  
  <p>e.g. Connect to the DB after initializing my app:</p>
  
  <pre><code>var mongo = require('mongoose');
  mongo.connect('mongodb://localhost/myDb');
  mongo.connection.on('open', function () {
    app.listen(3000);
  }
  </code></pre>
  
  <p>I found the connect-mongodb module, but I don't know how to implement it using mongoose, or if it's actually possible?
  I need to add something like this:</p>
  
  <pre><code>var mongoStore = require('connect-mongodb');
  // ...
  app.use(express.session({
    secret: 'topsecret',
    maxAge: new Date(Date.now() + 3600000),
    store: new mongoStore({ db: 'myDb' })
  }));
  </code></pre>
  
  <p>or do I have to define my db connection a second time using the mongodb-module directly?</p>