Unobtrusive middleware to add support for Express 3 sessions.

npm install
21 downloads in the last week
83 downloads in the last month

Unobtrusive middleware to add Express 3 session capability.

npm install

This module uses io.set('authorization') to add a session property to socket.handshake.

var express = require('express')
  , MongoStore = require('connect-mongo')(express)
  , ioSession = require('');

var app = express();

var sessionKey = 'secret key'
var memoryStore = new MongoStore({ db: 'name', url: MONGO_URI + '/name' });
app.use(express.session({ secret: sessionKey, store: memoryStore }));

var io = require('').listen(server);
io.set('authorization', ioSession(express.cookieParser(sessionKey), memoryStore));

io.on('connection', function (socket) {


You can use your own authorization function as the last argument after the session is added:

ioSession(cookieParser, memoryStore, [session sid key], [authorization(data, accept)])



npm loves you