I am using socket.io along with express sessions. I am using their middleware to get the cookie in the header, like:
io.use(function(socket, next) {
console.log(socket.handshake.headers.cookie);
next();
}); which puts this to the console:
io=ELJQk5v7q-jjZ5d_AAAA; connect.sid=s%3A17faf004-46c7-4219-9dac-81853ada8cab.ZzFPL%2BpHY9hNxEMDcLesnGEbuZyU9mOwVBZNEBuHzKA
Ok, great! Now I have the cookie, but how do I get the information out of it. I am thoroughly confused.
My session is initialized like this:
app.use(session({ //using express-session
genid: function(req) {
return uuid.v4();
},
secret: 'operation',
resave: false,
saveUninitialized: true
}));
I've searched far and wide over a simple explanation, but I have not found one. Is it required that I use sessionStore? If so why? I've tried different modules that are supposedly set up to handle this, but so far none of them have worked. I am using MongoDB, so I wouldn't mind storing them there if it is necessary, but I want to avoid using Redis to handle this as others have.