title: Setting up sessions on express app on multiple dynos heroku app
body: <p>I have implemented some user authentication on a single Heroku dyno using express (node.js)+ mongodb and everything is working fine. However, when I increase the number of dynos (more than 1), I cannot login, I keep being redirected on my login page, meaning my session hasn't been set. Here is my code:</p>
  
  <p>checkCookies = function(req, res, next) {</p>
  
  <pre><code>  if(req.session.user){
     res.locals.user = req.session.user;
     next();
    }
    else{
      res.redirect('/login');
    }
  };
  app.use(express.cookieParser());
    app.use(express.session({ secret: '0GBlJZ9EKBt2Zbi2flRPvztczCewBxXK',
    cookie: {httpOnly: true, maxAge:14*24*60*60*1000}
    }));
  </code></pre>
  
  <p>What is the best solution to handle shared session on express/node.js using mongodb?</p>