mercredi 20 février 2019

Laravel session flash messages are not showing on production (Laravel Forge)

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="" class="form">
    @csrf

    @if(session('message'))
        <div class="alert alert-success">
            
        </div>
    @endif

    @if (session('login_error'))
        <div class="alert alert-danger" role="alert">
            
        </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!');
}

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?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire