title: NODE JS Socket IO: req, res
body: <p>I use node js and socket io on my website and i have a problem, i want to connect my client on my website when my "client.on('Connexion', function(data) { } " is called, and i have a problem :</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>/* ------- CALLBACK CONNECTION : --------*/
  
  io.sockets.on('connection', function (client, req, res) {
  
    client.on('Connexion', function(data) {
          blabla...
          if(results[0]) {
            req.session.id = results[0];
            req.session.firstname = results[1];
            req.session.lastname = results[2];
            req.session.email = results[4];
            req.session.birthdate = results[5];
            req.session.phonenum = results[6];
            res.redirect("http://mydomain/" + "espace-client/");
                            
            /* HERE, req.session give and error --&gt; TypeError: Cannot read property 'session' of undefined */ 
           }           
      }
  });
    
   
  /* ------- I HAVE TEST THIS AND IT WORKS FINE : --------*/
    
  app.get('/test/', function(req, res) {
     req.session.id = "45";
     res.send(req.session.id);
  });</code></pre>
  </div>
  </div>
  </p>
  
  <p>Thank you in advance :)</p>