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

Azodian's avatar

Problems with (Session flash) in laravel 5.3

Hi all, I have problems with "session flash" in laravel 5.3 does not work after you redirect, but if it works when it returns in a view.

I make a redirect from Paypal

Route::get('paypal/cancel/{id}', function($id){
            
            session()->flash('pp_cancel', 'Transation Canceled');
           return redirect("item/".$id);
    });

But the view does not capture the session, which will be the problem.

Thank you very much that you can help

0 likes
3 replies
MarioMacedo's avatar

I'm facing the same problem. I double checked my middlewares and my controllers to have sure there weren't any "lost" redirects and also removed middleware "web" from web.php file, once it was being loaded twice per route.

So, @Azodian did you find a solution?

Azodian's avatar

I placed

session()->put('pp_cancel', 'Transation Canceled');

in views

@php session()->forget('pp_cancel') @endphp

At the end of the file

ejdelmonico's avatar

Are you using Debugbar? You can easily see what's stored in the session.

Please or to participate in this conversation.