1var session = require('express-session');
2var MongoStore = require('connect-mongo')(session);
3var mongoose = require('mongoose');
4mongoose.connect('mongodb://localhost/sess');
5app.use(express.session({
6 secret:'secret',
7 maxAge: new Date(Date.now() + 3600000),
8 store: new MongoStore(
9 // Following lines of code doesn't work
10 // with the connect-mongo version 1.2.1(2016-06-20).
11 // {db:mongoose.connection.db},
12 // function(err){
13 // console.log(err || 'connect-mongodb setup ok');
14 // }
15 {mongooseConnection:mongoose.connection}
16 )
17}));