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

hjortur17's avatar

How to use session for flash message

I was watching Jeffrey using session for flash message, but I'm wondering if it's possible to add title and message to a flash message and how would I access it?

What I came up with was something like this:

return redirect('/')->with('flash', [
    'title' => 'Bókun Staðfest!',
    'message' => 'Bókun þín hefur verið staðfest. Við höfum sent þér staðfestingu á netfangið þitt'
]);

But how would I access this?

WHAT I'M DOING NOW

<flash message="{{ session('flash') }}"></flash>
0 likes
1 reply
edoc's avatar
edoc
Best Answer
Level 24

You are on the right track. Try like you access a Js object like this flash.title flash.message

Please or to participate in this conversation.