node.js - How to parse socket.io handshake cookie -


i using socket.io along express sessions. using middleware cookie in header, like:

io.use(function(socket, next) { console.log(socket.handshake.headers.cookie); next(); 

}); puts console:

io=eljqk5v7q-jjz5d_aaaa; connect.sid=s%3a17faf004-46c7-4219-9dac-81853ada8cab.zzfpl%2bphy9hnxemdclesngebuzyu9mowvbznebuhzka 

ok, great! have cookie, how information out of it. thoroughly confused.

my session initialized this:

app.use(session({ //using express-session genid: function(req) {     return uuid.v4(); }, secret: 'operation', resave: false, saveuninitialized: true 

}));

i've searched far , wide on simple explanation, have not found one. required use sessionstore? if why? i've tried different modules supposedly set handle this, far none of them have worked. using mongodb, wouldn't mind storing them there if necessary, want avoid using redis handle others have.

after hours , hours, days , days of searching solution problem found solution work. if has similar issues encourage them use express-socket.io-session module. works great! saved me lot of frustration. of other modules have tried did not work , more complicated wanted them be.

https://www.npmjs.com/package/express-socket.io-session


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -