Skip to content

Instantly share code, notes, and snippets.

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 matylla/981253 to your computer and use it in GitHub Desktop.
Save matylla/981253 to your computer and use it in GitHub Desktop.
// helper function that goes inside your socket connection
client.connectSession = function(fn) {
var cookie = client.request.headers.cookie;
var sid = unescape(cookie.match(/connect\.sid=([^;]+)/)[1]);
redis.get(sid, function(err, data) {
fn(err, JSON.parse(data));
});
};
// usage
client.connectSession(function(err, data) {
console.log(data);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment