Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.x] Fix database session driver keeps resetting CSRF token #42782

Merged

Conversation

Hussam3bd
Copy link
Contributor

We have a multi-tenant app that runs on multiple servers using a load balancer, and as the app is load balanced across multiple servers, we are using a centralized store that all servers can access which is Redis.

Everything is working just fine on Redis driver, but when we changed the session driver to database we start having an issue with CSRF token and the token keep changing on every request and that caused CSRF Token Mismatch exception.

After a lot of debugging, I found that the issue was not with session config or the front-end request, it was from the payload column in the sessions table in the database, the session payload was too long and that caused an issue on decrypting the payload which is causing the mismatch and missing token.

We fixed is issue by changing the payload column from text to longText, and it worked!

This issue was reported in #13570

@Hussam3bd Hussam3bd changed the title change payload column to long text in sessions table Fix database session driver keeps resetting CSRF token Jun 12, 2022
@Hussam3bd Hussam3bd changed the title Fix database session driver keeps resetting CSRF token [9.x] Fix database session driver keeps resetting CSRF token Jun 12, 2022
@taylorotwell taylorotwell merged commit 2eef351 into laravel:9.x Jun 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants