Sometimes you may wish to store items in the session for the next request. You may do so using the flash method. Data stored in the session using this method will be available immediately and during the subsequent HTTP request. After the subsequent HTTP request, the flashed data will be deleted. Flash data is primarily useful for short-lived status messages:
In this topic, we will do an example for authentication form.
In the file LoginController.php, we add an error
Session::flash('error','Email and password are wrong!!!');
in the alert.blade.php, we add the checking
@if(Session::has('error'))
<div class ="alert alert-danger">
{{Session::get('error')}}
</div>
@endif
Add source code for success
@if(Session::has('success'))
<div class ="alert alert-success">
{{Session::get('success')}}
</div>
@endif