title: Socket IO using express session - socket.request.res undefined
body: <p>I am currently trying to implement session management using express 4.x and socket io 1.4, referencing <a href="https://stackoverflow.com/questions/25532692/how-to-share-sessions-with-socket-io-1-x-and-express-4-x">this answer</a>. The problem is that the second argument to the express session function is the res (response) object which is returning 'undefined' in my route. Is this question outdated or am I doing something wrong?</p>
  
  <pre><code>var http = require('http');
  
  var session = require('express-session')(
  {
    saveUninitialized : false,
    resave:false,
    secret:'secretstuff',
    cookie : {
      path : '/'
    }
  }
  );
  
  var express = require('express');
  
  var app = express();
  
  app.use(session)
  
  var http_server = http.createServer(app);
  
  var io = require('./sockets')(http_server,session);
  </code></pre>
  
  <p>here is my sockets.js</p>
  
  <pre><code>var Server = require('socket.io');
  
  module.exports = function(http_server, session)
  {
     var io = new Server(http_server);
  
     io.use(function(socket,next){
  
        //socket.request.res === undefined
        session(socket.request, socket.request.res,next);
     })
  
  }
  </code></pre>
  
  <p>which is where I get </p>
  
  <blockquote>
    <p>Uncaught TypeError: argument res is required</p>
  </blockquote>