diff --git a/config/lib/socket.io.js b/config/lib/socket.io.js index aa613c267c..a7bbc7b5c0 100644 --- a/config/lib/socket.io.js +++ b/config/lib/socket.io.js @@ -71,10 +71,15 @@ module.exports = function (app, db) { // Use the 'cookie-parser' module to parse the request cookies cookieParser(config.sessionSecret)(socket.request, {}, function (err) { // Get the session id from the request cookies - var sessionId = socket.request.signedCookies['connect.sid']; + var sessionId = socket.request.signedCookies ? socket.request.signedCookies[config.sessionKey] : undefined; + + if (!sessionId) return next(new Error('sessionId was not found in socket.request'), false); // Use the mongoStorage instance to get the Express session information mongoStore.get(sessionId, function (err, session) { + if (err) return next(err, false); + if (!session) return next(new Error('session was not found for ' + sessionId), false); + // Set the Socket.io session information socket.request.session = session;