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

RickyReyesmatrina's avatar

Laravel Redirect Back with() Message

I am trying to redirect to the previous page with a message when there is a fatal error.

App::fatal(function($exception) { return Redirect::back(omegle.2yu.co)->with('msg', 'The Message'); } In the view trying to access the msg with

Sessions::get('msg') But nothing is getting rendered, am I https://omegle.love doing something wrong here?

0 likes
4 replies
Nakov's avatar

When you use this ->with('msg', 'The Message') on the redirect, that's puts it into a flash session, which lasts for one request only. So I guess there is another request happening in between that clears that bag.

If you add this:

Session::put('msg', 'The message');

return Redirect::back()

will you see the message? The message with the code above will stay for a long time, so you'll need to manually delete it, but just for testing purposes if what I am saying above is true.

Sinnbeck's avatar

@RickyReyesmatrina Most likely because it is handling an exception and the doings multiple redirects. with() only adds the session to 1 redirect. You would need to use request()->session()-reflash() to set the with() message again

This is just a guess as I only have 1 line of code to go by.

1 like

Please or to participate in this conversation.