Laravel 419 | Session Expired

Viewed 311

I've been having an issue with Laravel sessions while logging in.

1.Yes, I do have a CSRF token included in my form.

2.Yes, the token has not expired.

3.Yes, the SESSION_SECURE_COOKIE is set to false.

I'm using redis as my SESSION_DRIVER and the expiration time is set to 120 minutes.

The thing that bothers me the most is that 'sometimes it works, and sometimes it does not'.

If I were to open an incognito tab and try to login, 10/20 times it would work without any problems whatsoever, yet the other 10 would result in a

[419 | Session Expired] error

.

My environment is CentOS, Nginx.

There aren't any proxies, and I'm not using Cloudflare either.

I'm really flabbergasted because the behavior is not consistent, it's literally random behavior which results in a successful or an unsuccessful login.

Does anyone have any ideas what might be the case?

1 Answers

To solve this error you first need to insert one of the following commands into the form tag.

@csrf OR {{ csrf_field }}

If your problem is not resolved, do the following: (Note that one of the above commands must be in the form tag)

1.Insert one of the following commands into the form tag @csrf OR {{ csrf_field }}

2.Open the .env file and change the values ​​to the "file" in the SESSION_DRIVER section.

3.Then you should reset laravel cache. type below commands in the terminal

php artisan view:clear php artisan route:clear php artisan cache:clear

php artisan config:cache OR php artisan optimize

4.In the final step, unplug the project from the serve and click again on php artisan serve

I hope your problem is resolved

Related