-
Laravel Version10.23.1 PHP Version8.1.12 Database Driver & VersionNo response DescriptionOn Friday, 9/15/23, Laravel version 10.23.1 was released. Edge & Chrome also had updates that day, versions 117.0.2045.31 and 117.0.5938.89 respectively. Before that Friday, there were no issues with my Laravel project. I received an notice from a user that day that they were encountering a 419 error message when they tried to login. Today the issue remains and is across all environments. Local dev, Server Dev and Production. Whenever a user tries to log in; when they lad on the login page, when using either Chrome or Edge, they are immediately prompted with an alert notifying them that the page has expired and to please refresh. I've modified code to get me straight to the login, and when I try to the POST route takes me to a 419 | Page Expired error page. On the login blade, I'm using a form post to send the users login details to the controller. In it is "@csrf" tag as mentioned in the laravel documentation. So it's getting and using the correct token. But when the login button is pressed, all the way in the vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken, in the tokensMatch function: The $token variable and the $request->session()->token() are not the same. Important Notes:
Any and all advice is welcome. Steps To Reproduce
|
Beta Was this translation helpful? Give feedback.
Replies: 19 comments 3 replies
-
Do you mean that they see the CSRF error when first going to the form, or after submitting? Does it happen when you manually type the direct login URL into the browser? |
Beta Was this translation helpful? Give feedback.
-
So downgrading doesn't make any difference? |
Beta Was this translation helpful? Give feedback.
-
Correct, downgrading Laravel made no difference. |
Beta Was this translation helpful? Give feedback.
-
After submitting the form. |
Beta Was this translation helpful? Give feedback.
-
The thing about this issue that truly confuses me is that it only appears in the latest versions of Chrome & Edge. Users with versions 116 or older of Chrome or Edge work just fine. And the latest Firefox works perfectly. Unfortunately, due to the nature of my clients I cannot have them change browsers from Edge to Firefox. |
Beta Was this translation helpful? Give feedback.
-
In the config/session.php, I am setting 'same_site' to 'strict'. Also; When I follow the route, in Edge, from submitting the form all the way to the tokensMatch function in the vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken, and dump out the $token and dd out the $request->session()->token(), they are not the same. And yet when I do the same in Firefox, the tokens are the same. This is driving me crazy. |
Beta Was this translation helpful? Give feedback.
-
Try using |
Beta Was this translation helpful? Give feedback.
-
No noticeable difference. |
Beta Was this translation helpful? Give feedback.
-
I need to clarify my previous post about the |
Beta Was this translation helpful? Give feedback.
-
@JF-626164 If you open up the devtools in the affected chrome browser do you see any blocked cookies within the console or the networking tab? |
Beta Was this translation helpful? Give feedback.
-
I do not see any blocked cookies. The only error I see is when the |
Beta Was this translation helpful? Give feedback.
-
@JF-626164 Which session store do you use? |
Beta Was this translation helpful? Give feedback.
-
Redis |
Beta Was this translation helpful? Give feedback.
-
Could having |
Beta Was this translation helpful? Give feedback.
-
I tried setting the |
Beta Was this translation helpful? Give feedback.
-
I've changed the session driver to be With Chrome, Edge, and Firefox, when I land on the login page a single csrf token is created. I have a message that the users must click "I Accept" to before they can login. Attempting to login with Chrome & Edge fails, csrf token mismatch. While Firefox succeeds. Looking in the browser developer tools: When I click accept in Chrome, a new token gets created in the storage. Not so with Firefox. When I login with Firefox, thats when I get the laravel_token. I believe Firefox is correctly getting the token from the user session, while Edge & Chrome are failing. |
Beta Was this translation helpful? Give feedback.
-
So far the only fix I've found for this is to add my login routes to the csrf exceptions list. |
Beta Was this translation helpful? Give feedback.
-
I've figured it out. This code has been in my project since April to make sure users didn't skip the login process. Its weird to me that it didn't cause an error like this back then. When Chrome & Edge updated last week, something related to that header must've been updated to work. Thank all of yall for trying to assist me with this. |
Beta Was this translation helpful? Give feedback.
I've figured it out.
In my auth code when rendering the auth.login view. I was loading the view with the header
clear-site-data: "cache", "cookies", storage", "executionContexts"
. When I removed thecookies
from the list, everything functioned perfectly fine.This code has been in my project since April to make sure users didn't skip the login process. Its weird to me that it didn't cause an error like this back then. When Chrome & Edge updated last week, something related to that header must've been updated to work.
Thank all of yall for trying to assist me with this.