Skip to content

Instantly share code, notes, and snippets.

@xmen4u
Created August 19, 2012 20:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xmen4u/3397357 to your computer and use it in GitHub Desktop.
Save xmen4u/3397357 to your computer and use it in GitHub Desktop.
node.js + redis + socket.io + should work but doesn't (express's prefix bug?)
io.configure(function() {
io.set('authorization', function(handshakeData, callback) {
if (handshakeData.headers.cookie) {
req_cookie = cookie.parse(decodeURIComponent(handshakeData.headers.cookie));
req_session = parseSignedCookie(req_cookie['connect.sid'], SECRET);
sessionStore.get(req_cookie['connect.sid'], function(err, session) {
if (session) {
req = {
sessionStore: sessionStore,
sessionID: handshakeData.sessionID
};
session = new express.session.Session(req, session);
console.log(JSON.stringify(session));
//handshakeData.session = new Session(handshakeData, session);
}
if (err || !session) {
console.log(JSON.stringify(session));
console.log(JSON.stringify(err));
console.log( 'Error!!!');
return callback(err, false);
}
else {
handshakeData.session = new Session(data, session);
return callback(null, true);
}
});
} else {
return callback('No cookie transmitted', false);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment