简体   繁体   中英

419 page expired in laravel 5.7

I am facing problem 419 page expired in Laravel 5.7 multiple authentications. If in case I try to log in user and admin in the same browser but in different tabs. Like in one tab user login screen is open and in the second tab admin login screen is open. First, I try to log in the normal user and user login is successful. But when I go to the second tab and try to log in the admin user, then in this case 419 page expired error is appearing. But if I refresh the second tab mean admin login page before the admin login attempt then admin works fine and logs in successfully without any error (419 page expired). Can you please help me to sort out this issue? I am already sending @csrf token with the form.

Before you login with any role, two pages have same token value. (Please check other articles about Laravel CSRF token)

在此处输入图像描述

在此处输入图像描述

Laravel automatically generates a CSRF "token" for each active user session managed by the application.

So, if you logged in, new user session will be started and CSRF token will be re-generated.

This is why you are getting 419 on admin page before refresh. If you refresh page, Laravel will render new token value.

Please test it on your browser using Inspect function.

I suffered from this problem and it turns out I had blocked all the browser cookies. Make sure your cookies are not blocked from the browser settings.

You could use WebSockets to refresh the token once you're logged in.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM