jaredhanson/connect-flash

req.flash() returning different values on same scope

muktaking opened this issue · 1 comments

I set a flash value as:
req.flash('error', 'Invalid email or password');

but when i accessing this in appropriate section with console.log, the results are different:

console.log(req.flash('error')); //output: ['Invalid email or password']
console.log(req.flash('error')); // output: []

what is reason? why it is returning different result?

You can only access your session flash k-v pair once. After the first access, it is destroyed.