node.js - Express: req.flash() requires sessions -


i'm having problems getting connect-flash work, error message i'm getting is:

'error: req.flash() requires sessions'

i've seen can because of ordering of app, i'm not sure if case here.

app.js:

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()); 

routes etc. below

flash generating code:

passport.authenticate('local', { failureredirect: '/login', successredirect: '/', failureflash: true}) 

is redis-server running? try

redis-server 

this solved issue me.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

node.js - Using Node without global install -

php - CakePHP HttpSockets send array of paramms -