— EDIT —
I wrote some middlware to do this: https://npmjs.org/package/flashify
So since the release of Express 3.0, the changes have removed req.flash()
https://github.com/visionmedia/express/wiki/Migrating-from-2.x-to-3.x (source)
So here is my question now. They have advised to use req.session.messages in a local to display a flash.
So to make a session accessible to the view, we have to do the following:
nb: In coffee-script
app.locals.use (req,res) ->
res.locals.session = req.session
How would we access the session data from the view then clear it? We can’t clear the contents of session after the view has rendered, but we can’t clear it because it wont reach the view so im a bit lost as to how one would get around this problem?
You can use the connect-flash middleware to add the req.flash() functionality back into express 3.0.