socket.io parse connect (>= 2.4.1) signed session cookie

前端 未结 1 1233
后悔当初
后悔当初 2021-02-05 18:31

With the latest version of connect (as of 2012-07-26), I\'ve found the following way to get a session ID from socket.io that will work with a connect-redis store.



        
相关标签:
1条回答
  • 2021-02-05 19:10

    I was running into the same and just wrote a tiny module to abstract it. Here's how its usage looks like. It was written and tested using express 3 so should work fine with connect 2.4.x. Please let me know otherwise.

    var SessionSockets = require('session.socket.io')
      , sessionSockets = new SessionSockets(io, sessionStore, cookieParser);
    
    sessionSockets.on('connection', function (err, socket, session) {
      //your regular socket.io code goes here
    });
    

    For more details on how it works see https://github.com/wcamarao/session.socket.io

    0 讨论(0)
提交回复
热议问题