I want people to login using a standard loginform and then join a socket.io chatroom if authentication was successful. I dont know how to retrieve the session when setting up the socket.io part. So far I have setup a session using:
app.use(express.cookieParser());
app.use(express.session({secret:'my-no-longer-secret-secret'}));
app.post('/login', function(request, response) {
// lookup credentials from database
var login = true;
if(login) {
request.session.authorized = true;
request.session.room = request.body['room'];
console.log("Sessino authorized: " + request.session.authorized);
console.log("Session room " + request.session.room);
}
else {
routes.login(request, response);
}
routes.index(request, response);
})
I want to be able to retrieve the request.session .someinfo here in the socket part but as I understand it, it is not possible. Instead I have to use a cookieSession but I am not sure how to do that.
Thank you in advance