Skip to content

Instantly share code, notes, and snippets.

@jeromeetienne
Created June 1, 2011 10:48
Show Gist options
  • Save jeromeetienne/1002105 to your computer and use it in GitHub Desktop.
Save jeromeetienne/1002105 to your computer and use it in GitHub Desktop.
// attempts to get flash/session accessible in any template
// - this middleware function fails and keep producing 'Error: req.flash() requires sessions'
// - this middleware has been place *after* session middleware in the stack
app.use(function(req,res, next){
console.log("flash middleware")
res.locals({
session : req.session,
flash : req.flash()
});
});
@andreydjason
Copy link

thanks @AlejandroMG, I'm was with "req.flash() requires sessions" error too, and this works for me as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment