Many articles (here's one) shows how to utilize the authorization event to extract the cookie of the express session:
io.set('authorization', function(data, accept) {
if (!data.headers.cookie) {
return accept('No cookie transmitted.', false);
}
else {
// extract the signed cookie..
}
I printed data.headers and there's no cookie property.
I've inspected the cookies (via Chrome developer tools) and connect.sid domain is localhost whereas io domain is 127.0.0.1. Maybe the problem is there but I'm not sure how to change it.
Another aspect is, the express cookie is used by server A (with port 3000) and the socket.io cookie is used by server B (with port 4000).
I'd be glad for a solution.
Thanks.
I just solved it actually. The problem was indeed with the domain. You should change the socket.io domain to localhost instead of 127.0.0.1.
Hope it will help someone!