Use the connect-mongo module with expression.
var http = require('http'), express = require('express'), session = require('connect-mongo')(express)
And then in your working session, settings for external storage. The code below will use a session from mongo, cookie and extra headers to allow cross-domain and jsonp.
app.configure(function() { app.use(express.cookieParser()); app.use(express.session({ store: new session({ db: 'sessions' }), secret: 'yoursecret', cookie: { path: '/', maxAge: 1000 * 60 * 60 * 24 // 1 day } })); app.use(function(req, res, next) { res.header('Access-Control-Allow-Credentials', true); res.header('Access-Control-Allow-Origin', req.headers.origin); res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE'); res.header('Access-Control-Allow-Headers', 'X-Requested-With, X-HTTP-Method-Override, Content-Type, Accept'); next(); }); app.set('jsonp callback', true); });
source share