Only call req.flash() when it is a defined function; fall back to setting a session variable