I’m using socket.io and express and have the following code:
io.set('authorization', function (data, accept) {
if (data.headers.cookie) {
data.cookie = parseCookie(data.headers.cookie);
data.sessionID = data.cookie['express.sid'];
data.sessionStore = session;
session.get(data.sessionID, function (err, session) {
if (err || !session) {
accept('Error', false);
} else {
data.session = new msession(data, session);
accept(null, true);
}
});
} else {
return accept('No cookie transmitted.', false);
}
});
session is a global variable.
The problem is, I’m trying to end the session by calling session.destroy() when the logout page is called….but it’s not ending. Is there anything additional I need to do?
You must call
session.destroy(sid, [optional callback function]);where sid is the session id. Here is the code for the Memory Store:https://github.com/senchalabs/connect/blob/master/lib/middleware/session/memory.js#L79-92