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

hotsaucejake's avatar

Redirecting With Flashed Session Data returns flashed session TWICE

This is annoying me. I'm successfully redirecting and flashing a status message, but it appears AGAIN if I click on another page. The next page click or redirect the session has cleared. I don't want this message to show up twice.

My controller

if($saved)
        {
            return redirect('/dashboard/school-year')
                ->with('toastr', 'Success!')
                ->with('success', 'New school year created.');
        } else {
            return redirect('/dashboard/school-year')
                ->with('toastr', 'Error!')
                ->with('error', 'Hmmm... there was some type of error with this.');
        }

my blade:

@if(session('toastr'))
    @if(session('success'))
        {{ \Toastr::success(session('success'), session('toastr'), $options = []) }}
    @elseif(session('error'))
        {{ \Toastr::error(session('error'), session('toastr'), $options = []) }}
    @elseif(session('warning'))
        {{ \Toastr::error(session('warning'), session('toastr'), $options = []) }}
    @elseif(session('info'))
        {{ \Toastr::error(session('info'), session('toastr'), $options = []) }}
    @endif
@endif

Again, it's working properly, it just shows twice (going to another page) before it's removed.

0 likes
2 replies
Snapey's avatar

does your dashboard display finish normally or do you halt it with dd or die ?

hotsaucejake's avatar

I ended up figuring it out. I did dd() for testing and noticed that it was being removed on the subsequent session, but my toatr alerts were still appearing. It had to do with the actual package. I looked at the source code and figured the problem out.

I ended up making a pull request on the package to fix it.

The package itself was also flashing to the session which caused it to appear twice because it wasn't being properly flushed.

Please or to participate in this conversation.