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

asdasdsa's avatar

Flash messages to session Laravel 5.3

Hi!

I was following the screencast https://laracasts.com/series/laravel-5-from-scratch/episodes/15 and the I noticed it was from mars 14th.

Went over to the docs https://laravel.com/docs/5.3/session and tried to follow along with the docs on how to set up some session flashing.

Ran the command php artisan session:table and got myself a migration.

I flash to the session with $request->session()->flash('status', 'Task was successful!');

I can retrieve the flash with

                    @if(Session::has('status'))
                        <div class="alert">
                            {{ Session::get('status') }}
                        </div>

I can see in the table that I have a flash in the sessions table. But I thought that it would disappear from the table. According to the docs

Sometimes you may wish to store items in the session only for the next request. You may do so using the flash method. Data stored in the session using this method will only be available during the subsequent HTTP request, and then will be deleted. Flash data is primarily useful for short-lived status messages:

So how do I properly use the session flash with Laravel 5.3?

0 likes
1 reply
ejdelmonico's avatar

Table? Are you storing sessions in the DB? I do not so I can not reproduce without setting a new project up. If you are a fan of Laravel Debugbar, you can see the session data and watch it clear after the next request. Using a table, you are most likely going to have to remove the record. I use the file system driver.

// return form data
$data = $request->all();

// save data to session to send mail
session()->flash('info', $data);

// Get form data in next request which empties it!
$data = session()->get('info');

Please or to participate in this conversation.