Skip to content

Instantly share code, notes, and snippets.

@yairEO
Last active December 20, 2015 19:49
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 yairEO/6186034 to your computer and use it in GitHub Desktop.
Save yairEO/6186034 to your computer and use it in GitHub Desktop.
get Passport login details within socket.IO
io.sockets.on('connection', function (socket){
try{
var profileCookie = cookie.parse(socket.handshake.headers['cookie']),
profile;
if( profileCookie && profileCookie['connect.sess'] ){
profile = profileCookie['connect.sess'];
profile = JSON.parse(profile.slice(profile.indexOf('{'), profile.indexOf('}.') + 1));
}
}
catch(err){}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment