I'm trying to implement sessions in my node.js
app which makes heavy use of socket.io
. I'm struggling with this currently, and found a rather simple solution which recommends using the socket itself to store the session information. For example:
socket.on('login', function(username) {
if (loginSuccessful() {
socket.sessionID = generateSessionId();
}
});
socket.on('logout', function(username) {
socket.sessionID = null;
});
I am worried that such a simple solution wouldn't be secure, however, I'm not sure if there is any clear vulnerability this solution would have.