Skip to content

SQL errors when using the database driver for sessions are suppressed. #57961

@lucasvmds

Description

@lucasvmds

Laravel Version

12.32.5

PHP Version

8.3.27

Database Driver & Version

MySQL Server version: 8.0.44-0ubuntu0.24.04.1 (Ubuntu)

Description

When attempting to create a session and receiving an SQL error, the framework ignores the error and tries to update the session.
This makes it difficult to identify errors (I just experienced this).
This happens on line 154 of the src/Illuminate/Session/DatabaseSessionHandler.php file.

This seems redundant since the write() method checks if the session exists or not, determining whether to create or update it.

I ran into this problem because I was having trouble validating the CSRF token.
I was able to make the request (/sanctum/csrf-token), receive the cookies correctly, but kept getting error 419 when using the token.
When I checked the session table, I saw that there were no records. That's when I found the problem.

Steps To Reproduce

  1. Create a new application.
  2. Configure the session driver as a database.
  3. Create any column as mandatory in the migration of the sessions table.
  4. Try to use the session.
  5. You will notice that the record in the sessions table will not be created and there will also be no errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions