Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Toughoj's avatar

Cant override session flash messages

I am adding a flash messages in case of a successful login , after login I am checking some conditions and I am attempting to override the initial message but with no luck , I end up with two flash messages the initial one and the one added if in case one of the condition where true (which I am checking in the middleware) , I tried a couple of things including:

session()->forget('flash_notification');
session()->regenerate();
session()->pull('flash_notification');

but whenever I add the flash('new message in the middleware') both old and new messages get displayed

0 likes
4 replies
Toughoj's avatar

I am using the following method :

flash('message')->success();

Please or to participate in this conversation.