Support the ongoing development of Laravel.io →
Laravel Session Blade

Hi,

I have a problem with a redirect -> with message

In my controller, I have a return redirect as below : return redirect(route('multiHikes.index'))->with('message', 'Hikes non créé');

In my view (createMultiHikes), I have this : @if (session('message')) <div class="alert alert-success"> {{ session('message') }} </div> @endif The route "multiHikes.index" return the view "createMultiHikes"

when I debug the return, in the _flash, I do have a message created with its contents... but when I debug the "session::all()" in the view, it's empty

I don't understand why I can't get the message out in the view. Thank you for your answers.

Last updated 2 years ago.
0

Try this:

return redirect()->route('multiHike.index')->with('message', 'Hello');

Or

return redirect()->route('multiHike.index', ['messag' => 'Your messge']);

Also see the examples on the docs: Redirecting named routes

I personally never pass the argument for a redirect.

Last updated 5 years ago.

lcallif liked this reply

1

Thank you Paulo!!!! Yeahhhhh.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Cherson gamars99 Joined 11 Mar 2020

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.