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

Session Payload Size Issue with Database Driver #53277

Open
faisal975Hexolt opened this issue Oct 23, 2024 · 2 comments
Open

Session Payload Size Issue with Database Driver #53277

faisal975Hexolt opened this issue Oct 23, 2024 · 2 comments

Comments

@faisal975Hexolt
Copy link

Laravel Version

11

PHP Version

8.2.12

Database Driver & Version

No response

Description

I recently switched my session driver from "file" to "database," and I encountered a frustrating issue where I was losing sessions soon after login. I spent three days troubleshooting the code, unable to pinpoint the problem.

After much investigation, I discovered that the session payload was larger than the allowable size of the text field in the sessions table in the database. Instead of throwing an SQL error, the framework silently saved an incomplete payload string, which rendered it useless.

I believe it would be beneficial for future developers to address this issue. It would be more helpful if Laravel could provide an SQL error when the session payload exceeds the maximum size for the database field, preventing the saving of incomplete session data.

I hope this feedback helps improve the framework for others.

Steps To Reproduce

add some more data in session a part from authentiaction that could not fit in sessions.payload

Copy link

Thank you for reporting this issue!

As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub.

If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team.

Thank you!

@mkubenka
Copy link

I noticed the issue was caused by a try/catch block in the database session handler, which silently suppresses the error:

https://github.com/laravel/framework/blob/11.x/src/Illuminate/Session/DatabaseSessionHandler.php#L159

Improving this behavior could greatly benefit developers by providing more explicit feedback on why session data isn't being saved correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants