title: Socket.io io.use fails - TypeError: io.use is not a function
body: <p>I'm working on a project that needs socket handshake session I'm trying to get this code to work, that I got it from <a href="https://www.npmjs.com/package/express-socket.io-session" rel="nofollow">https://www.npmjs.com/package/express-socket.io-session</a></p>
  
  <pre><code>var app = require('express')(),
    server  = require("http").createServer(app),
    io = require("socket.io")(server),
    session = require("express-session")({
      secret: "my-secret",
      resave: true,
      saveUninitialized: true
    }),
    sharedsession = require("express-socket.io-session");
  
  
  // Attach session
  app.use(session);
  
  // Share session with io sockets
  
  io.use(sharedsession(session));
  
  io.on("connection", function(socket) {
  
      // I've add this one...
      console.log(socket.handshake.session);
  
      // Accept a login event with user's data
      socket.on("login", function(userdata) {
          socket.handshake.session.userdata = userdata;
      });
      socket.on("logout", function(userdata) {
          if (socket.handshake.session.userdata) {
              delete socket.handshake.session.userdata;
          }
      });        
  });
  
  server.listen(3000);
  </code></pre>
  
  <p>I run it and first I got this </p>
  
  <pre><code>var io = require("socket.io")(server);
                               ^
  
  TypeError: require(...) is not a function
      at Object.&lt;anonymous&gt; (/Users/Jack/Root/Sites/Scopone/provaric/server.js:8:30)
      at Module._compile (module.js:435:26)
      at Object.Module._extensions..js (module.js:442:10)
      at Module.load (module.js:356:32)
      at Function.Module._load (module.js:313:12)
      at Function.Module.runMain (module.js:467:10)
      at startup (node.js:136:18)
      at node.js:963:3
  </code></pre>
  
  <p>solved adding</p>
  
  <p>io = require("socket.io").listen(server);</p>
  
  <p>and then I got this one</p>
  
  <pre><code>io.use(function(socket, next) {
      ^
  
  TypeError: io.use is not a function
      at Object.&lt;anonymous&gt; (/Users/Jack/Root/Sites/Scopone/provaric/server.js:15:5)
      at Module._compile (module.js:435:26)
      at Object.Module._extensions..js (module.js:442:10)
      at Module.load (module.js:356:32)
      at Function.Module._load (module.js:313:12)
      at Function.Module.runMain (module.js:467:10)
      at startup (node.js:136:18)
      at node.js:963:3
  </code></pre>
  
  <p>Any ideas to fix this?</p>
  
  <p>socket.io@0.9.17</p>