@khizerrashid I think the following code should be enough to display the session message. Why do you use extra if-else conditions? Do you really need that?
@if(Session::has("form_submit_flag")
{!! session("form_submit_msg") !!}
@endif
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am working on a Laravel project in which I am using flash session after form submit to display the message. But the problem is that the flash session message sometimes appears and sometime not. I know this issue occurs when we use a web middleware twice. But I did not use twice. It Applies as default. So what can be the other cause for this problem. Here is some piece of code. In controller function after saving data: return redirect()->back()->with(['form_submit_flag' => 'true', 'form_submit_msg' => 'Department Edited Successfully']);
In blade: @if(Session::has("form_submit_flag")) @if(session("form_submit_flag") == "true")
× Message! {!! session("form_submit_msg") !!}@elseif(session("form_submit_flag") == "false")
× Message! {!! session("form_submit_msg") !!} @endif @endifPlease or to participate in this conversation.