I have a Laravel Blade form that is not displaying flash session error messages on my production site. It was previously giving 419 error response "Sorry, your session has expired. Please refresh and try again. on production laravel". I was able to clear that so the form submits by clearing the cache and composer dump-autoload.
This is the form to display the sessions. Works locally, I am on L5.7.9.
<form method="POST" action="{{ route('candidates.store') }}" class="form">
@csrf
@if(session('message'))
<div class="alert alert-success">
{{ session('message') }}
</div>
@endif
@if (session('login_error'))
<div class="alert alert-danger" role="alert">
{{ session('login_error') }}
</div>
@endif
@if ($errors->any())
<div class="alert alert-danger" role="alert">
Woops had some problems saving
</div>
@endif
In my .env file I have:
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_DOMAIN=employbl.com
QUEUE_DRIVER=sync
Then in the controller store method I have:
public function store(Request $request)
{
$validator = $request->validate([
'first_name' => 'required',
'last_name' => 'required',
'email' => 'email|required|unique:users',
'linkedin_url' => 'required|url',
'phone_number' => 'required',
'work_authorization' => 'required',
'city' => 'required',
'state' => 'required'
]);
$candidate = new User($request->all());
$candidate->active = false;
$candidate->save();
return redirect()->route('candidates.landing')->with('message', 'Successfully applied to join Employbl network!');
}
For routes I do not have a route group:
Route::get('/candidates', 'CandidateController@landing')->name('candidates.landing');
Route::post('/candidates', 'CandidateController@store')->name('candidates.store');
php artisan route:list shows that I am only using the web middleware once:
| | POST | candidates | candidates.store | App\Http\Controllers\CandidateController@store | web |
The flash messages are working locally, but when I submit the form on production (deployed with Laravel Forge) the form submits but no flash messages are displayed. What can I do to make the session messages appear on production and why is this happening?