title: how to use express Session
body: <p>I am a express freshman, I have a problem with session now. this code I can't store seesion. req.session.user is undefined, maybe the quession was the session not store. what's wrong of my code, please tell me my wrong please thanks</p>
  
  <pre><code>var express = require('express');
  var bodyParser = require('body-parser');
  var expressSession = require('express-session');
  var cookieParser = require('cookie-parser');
  var app = express();
  app.use(cookieParser());
  app.use(expressSession({
      secret: 'keyboard cat',
      resave: false,
      saveUninitialized: true,
      cookie: { secure: true }
  }))
  var auth = function(req, res, next) {
      console.log(req.session.user);  **this is undefined**
      if (req.session &amp;&amp; req.session.user === "amy" &amp;&amp; req.session.admin)
          return next();
      else
          return res.sendStatus(401);
  };
  app.get('/login', function (req, res) {
      if (!req.query.username || !req.query.password) {
          res.send('login failed');
      } else if(req.query.username === "amy" || req.query.password === "amyspassword") {
          req.session.user = "amy";
          req.session.admin = true;
          res.send(req.session.user);
      }
  });
  app.get('/logout', function (req, res) {
      req.session.destroy();
      res.send("logout success!");
  });
  app.get('/content', auth, function (req, res) {
      res.send("You can only see this after you've logged in.");
  });
  app.listen(3000);
  </code></pre>