title: Session is not working in express js
body: <p>I'm creating login application using express-session. When I login to the application via post request the the cookie will created,but Session is not working for me. </p>
  
  <p>Server.js</p>
  
  <pre><code>var bodyParser = require('body-parser');
  var cookieParser = require('cookie-parser');
  var session = require('express-session');
  app.use(cookieParser());
  
  app.use(session({
    key: 'user_sid',
    secret: 'somerandonstuffs',
    resave: false,
    saveUninitialized: false,
    cookie: {
      expires: 600000
    }
  }));
  var sessionChecker = (req, res, next) =&gt; {
    if (req.session.user &amp;&amp; req.cookies.user_sid) {
      res.redirect('/');;
    } else {
      next();
    }
  };
  app.post('/login', function (req, res) {
    console.log(req.session.user)
    if (req.session.user &amp;&amp; req.cookies.user_sid) {
      result = { "message": "loggedinwithsession" };
      res.send(result);
    } else {
      var data = req.body;
      var responseData = {};
      console.log(data);
      res.setHeader('Content-Type', 'application/json');
      controller.cont.login(data.email, data.password).then(result =&gt; {
        res.send(result),
          req.session.user = result;
      }
      ).catch(result =&gt; res.send(result))
    }
  })
  </code></pre>