node.js - Error: req.flash() requires sessions -
i'm new node , i'm pretty sure i've set middle ware , express use flash messaging still error:
error: req.flash() requires sessions
setup
//express.js var flash = require('connect-flash') module.exports = function (app, config, passport) { app.use(flash()); }; //route js exports.loginget = function (req, res) { res.render('users/login', { title: 'login', message: req.flash('error') //error in question }); };
what else can make sure have set correctly , working?
from readme (emphasis mine):
flash messages stored in session. first, setup sessions usual enabling cookieparser , session middleware. then, use flash middleware provided connect-flash.
using express-sessions
express 4, cookieparser
no longer required.
var session = require('express-session'); //... app.use(session({ cookie: { maxage: 60000 }, secret: 'woot', resave: false, saveuninitialized: false}));
Comments
Post a Comment