Unfortunately socket.io developer team decided to deprecate functions set() and get(). The problem is that these two functions allowed us to save variable into session.
So my question is : What is the equivalent of the folloing code on socket.io 1.0.5 ?
socket.set('mySessionVar', 'myValue');
socket.get('mySessionVar', function (error, mySessionVar) {
console.log('I have a super variable save in the session : '+mySessionVar);
socket.emit('mySessionVar', mySessionVar);
});
Thank you for your help, Guillaume.
socket.io-handshake is session middleware for socket.io 1.x. It is built on top of express-session and cookie-parser. I know we are talking about socket.io and not express, but it still works with socket.io. This example will make your sessions live on a redis store.
Your 'socket' is a Javascript object, to which you can add any additional key/values.