Created
January 23, 2014 10:43
-
-
Save baniol/8576533 to your computer and use it in GitHub Desktop.
nodejs, express, flash messages, session
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://stackoverflow.com/a/12254857 | |
app.use(function(req, res, next) { | |
var session = req.session; | |
var messages = session.messages || (session.messages = []); | |
req.flash = function(type, message) { | |
messages.push([type, message]); | |
}; | |
next(); | |
}); | |
// And in your view just do message = messages.pop(). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment