jaredhanson / connect-flash

Flash message middleware for Connect and Express.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

req.flash() returning different values on same scope

muktaking opened this issue · 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.