I cannot have Laravel 11 authentication working with MySQL or MariaDB.
Here's what I've done:
composer create-project laravel/laravel foo
.env
accordingly (connection is ok)composer require laravel/fortify
@csrf
is present in login and logout forms (it is)Here's what happens when I test in a browser:
When I try to log in with the test user, I'm not logged in, but I'm correctly redirected to the appropriate page configured in Fortify.
When I try to log in with the test user and the remember
checkbox, I do log in. But I cannot log out, I get a 419 page expired
error.
That's weird.
Here's weirer:
If I use SQLite, there is no problem: I can log in and out.
If I use MySQL/MariaDB and file
session driver, there is no problem either: I can log in and out too.
So, here's what works or not:
Database | Session driver | Remember me | Log in | Log out |
---|---|---|---|---|
MySQL / MariaDB | database | no | no | n/a |
MySQL / MariaDB | database | yes | yes | no |
MySQL / MariaDB | file | yes / no | yes | yes |
SQLite | database | yes / no | yes | yes |
SQLite | file | yes / no | yes | yes |
I have found nothing about such a problem (Laravel authentication with MySQL/MariaDB combined to session database driver) neither on SO nor in Laravel issues.
I'm running:
One thing I forgot to mention: I use UUID for users. Therefore, session table needs to be created accordingly:
Schema::create('sessions', function (Blueprint $table) {
// ...
$table->foreignUuid('user_id')->nullable()->index();