title: Get user id socket.io, passport, koa
body: <p>I'm using Koa, Passport.js and koa-session to authenticate users.
  So it basically looks like:</p>
  
  <pre><code>// session
  var session = require('koa-session');
  app.keys = [config.secret];
  app.use(session());
  
  
  // auth
  require(__dirname+'/lib/auth'); // de/serializeUser, strategies etc..
  var passport = require('koa-passport');
  app.use(passport.initialize());
  app.use(passport.session());
  </code></pre>
  
  <p>This works well. On requests I do have the <code>req.user</code>, with the user id. But when using sockets, I can do:</p>
  
  <pre><code>io.on('connection', function(socket) {
    console.log(socket.request.headers.cookie),
  });
  </code></pre>
  
  <p>But of course it's only the encrypted session ID, how could I deserialize the user and get the user.id just like I do when I get the <code>req.user</code> on get or post request?</p>
  
  <p>Thank you in advance.</p>