Skip to content

zemirco/primus-express-session

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

primus-express-session

Build Status NPM version

Share a user session between Express and Primus.

Important

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.

Test

grunt

License

MIT

About

Share a user session between Express and Primus

Resources

Stars

Watchers

Forks

Packages

No packages published