title: request.session.regenerate not working, undefined 'undefined'
body: <p>I've got this issue: </p>
  
  <pre><code>request.session.regenerate(function() {
  
                  request.session.user = username;
                  return response.send(username);
  });
  </code></pre>
  
  <p>When logging in I always get undefined error: </p>
  
  <pre><code>Cannot read property 'regenerate' of undefined
  </code></pre>
  
  <p>If I just leave <code>return response.send(username);</code> it works fine, however I need to create a session. </p>
  
  <p>What could be the issue?</p>
  
  <p><strong>More code</strong></p>
  
  <pre><code>router.post('/login', bodyParser, function(request, response) {
      var username = request.body.username;
      var password = request.body.password;
  
  
      adminUser.findOne({
          username: username
      }, function(err, data) {
          if (err | data === null) {
              return response.send(401, "User Doesn't exist");
          } else {
              var usr = data;
  
              if (username == usr.username &amp;&amp; bcrypt.compareSync(password, usr.password)) {
  
                  request.session.regenerate(function() {
  
                  request.session.user = username;
                  return response.send(username);
  
                  });
              } else {
                  return response.send(401, "Bad Username or Password");
              }
          }
      });
  });
  </code></pre>
  
  <p>Added: <code>app.use (session());</code></p>
  
  <p>Now its working. </p>