Carrot
Carrot
FFilament
Created by Carrot on 5/19/2025 in #❓┊help
419 error on login ONLY when session driver is "database"
After reading through the other posts involving 419 errors on Filament, I have not been able to resolve this issue. When setting the session driver to database, I get a 419 error on logging in, but if I change it to file instead of database it works perfectly fine. A few things: my users table uses uuids instead of an int, but I have updated the session table migration accordingly, migrated to a completely fresh database, and verified that the database connection works by using tinker to insert a new user into the database. My migration:
public function up(): void
{
/* ... */
Schema::create('users', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->foreignUuid('tenant_id')->nullable()->references('id')->on('tenants')->cascadeOnDelete();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});

Schema::create('sessions', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->foreignUuid('user_id')->references('id')->on('users')->nullable()->index();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->longText('payload');
$table->integer('last_activity')->index();
});
/* ... */
}
public function up(): void
{
/* ... */
Schema::create('users', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->foreignUuid('tenant_id')->nullable()->references('id')->on('tenants')->cascadeOnDelete();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});

Schema::create('sessions', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->foreignUuid('user_id')->references('id')->on('users')->nullable()->index();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->longText('payload');
$table->integer('last_activity')->index();
});
/* ... */
}
my .env:
.env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=atlas
DB_USERNAME=root
DB_PASSWORD=

SESSION_DRIVER=database
#SESSION_SECURE_COOKIE=true
#SESSION_COOKIE="atlas_session"
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/
SESSION_DOMAIN=null
.env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=atlas
DB_USERNAME=root
DB_PASSWORD=

SESSION_DRIVER=database
#SESSION_SECURE_COOKIE=true
#SESSION_COOKIE="atlas_session"
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/
SESSION_DOMAIN=null
I have no idea why changing the session driver to database impacts it like this, but it's only when the driver is database, if I change it to file it works
5 replies