/connect-mongodb

SessionStorage for connect's session middleware

Primary LanguageJavaScript

Connect MongoDB

connect-mongodb is a MongoDB session store backed by node-mongodb-native.

Originally written by dvv

Installation

Via git:

$ git clone git://github.com/masylum/connect-mongodb.git ~/.node_libraries/connect-mongodb

via npm:

$ npm install connect-mongodb

Options

  • dbname MongoDB db name
  • host MongoDB server hostname
  • port MongoDB server portno
  • collection MongoDB collection to host sessions. 'sessions' by default.

Example

var connect = require('connect')
      , mongoStore = require('connect-mongodb');

connect.createServer(
  connect.bodyDecoder(), // Always before the session
  connect.cookieDecoder(),
  connect.session({ store: mongoStore() })
);

Warning

If you use the bodyDecoder middleware, place it before the session one!