title: express session management not working
body: <p>I am new to the <code>node.js</code> world. I am trying to write a REST services and I am stuck with session management. So I created a separate app just to see if I can get the session to work, but it doesn't, here is the code. The <code>req.session.username</code> is always undefined:</p>
  
  <pre><code>var express = require('express');
  var url = require('url');
  
  var app = express()
  app.use(express.cookieParser('Hiren'))
  app.use(express.session({ secret: 'HirenAdesara' }))
  app.use(express.bodyParser())
  app.use(app.router)
  
  //Sniff HTTP
  app.all('*', function(req, res, next) {
      //Check for Authentication
              console.log(req.session)
      if ((!(/^\/auth/g.test(req.url))) &amp;&amp; (!req.session)) {
          console.log('in app.all: Unauthorized')
          res.send(401)
      }
      else
      {
          return next()
      }
  })
  
  app.post('/auth', function(req, res) {
                  var query =  req.body
                  console.log('Query' + JSON.stringify(query))
                  username = query.username;
                  password = query.password;
                  if(username == 'Hiren' &amp;&amp; password == 'Adesara')
                  {
                      req.session.username = 'Hiren';
                      console.log('New Session Created..')
                      res.send(200)
                  }
                  else
                  {
                      console.log('New session could not be created.')
                      res.send(401)
                  }
  })
  
  app.get('/projects', function(req,res) {
      console.log('inside projects' + req.session.username);
      res.send(req.session.username); })
  
  app.listen(2048)
  console.log('Listening on port 2048...')
  </code></pre>
  
  <p>It doesn't work and I have no idea what is wrong here.</p>