Share a user session between Express and Primus.
This is the branch for Express 4.x and Primus 2.2.x.
You don't need this plugin with newer versions of Express and Primus. Simply use middleware.
// .. express middleware
var cookies = cookieParser(secret);
app.use(cookies);
var session = cookieSession({keys: ['key1', 'key2']});
app.use(session);
// use the same middleware for primus
primus.before('cookies', cookies);
primus.before('session', session);
// access session similar to express requests
primus.on('connection', function(spark) {
console.log('on::connection');
var req = spark.request;
console.log(req.session.username);
});
For more information take a look at the example or the tests.
Take a look at the master branch for older versions.
grunt
MIT