title: Express: req.flash() requires sessions
body: <p>I'm having some problems getting connect-flash to work, the error message I'm getting is: </p>
  
  <p>'Error: req.flash() requires sessions'</p>
  
  <p>I've seen this can be because of the ordering of the app, but I'm not sure if this is the case here. </p>
  
  <p>App.js:</p>
  
  <pre><code>var express = require('express');
  var path = require('path');
  var favicon = require('serve-favicon');
  var logger = require('morgan');
  var cookieParser = require('cookie-parser');
  var bodyParser = require('body-parser');
  var session = require('express-session');
  var flash = require('connect-flash');
  var passport = require('passport');
  var app = express();
  
  app.use(logger('dev'));
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({ extended: false }));
  app.use(cookieParser());
  app.use(express.static(path.join(__dirname, 'public')));
  
  app.use(session({secret: '{secret}', name: 'session_id', saveUninitialized: true, resave: true}));
  app.use(passport.initialize());
  app.use(passport.session());
  app.use(flash());
  </code></pre>
  
  <p>Routes etc. are below</p>
  
  <p>flash generating code:</p>
  
  <pre><code>passport.authenticate('local', { failureRedirect: '/login', successRedirect: '/', failureFlash: true})
  </code></pre>