Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

it13's avatar
Level 1

Laravel Session Sharing using database session table

I will create schema like this Schema::create('sessions', function ($table) { $table->string('id')->unique(); $table->unsignedInteger('user_id')->nullable(); $table->string('ip_address', 45)->nullable(); $table->text('user_agent')->nullable(); $table->text('payload'); $table->integer('last_activity'); });

config.php

0 likes
1 reply
fylzero's avatar

@it13 You can actually do this with an artisan command...

php artisan session:table

php artisan migrate

Or

Run php artisan make:migration AddSessionsTable and edit the migration with...


Schema::create('sessions', function ($table) {
    $table->string('id')->unique();
    $table->unsignedInteger('user_id')->nullable();
    $table->string('ip_address', 45)->nullable();
    $table->text('user_agent')->nullable();
    $table->text('payload');
    $table->integer('last_activity');
});
24 likes

Please or to participate in this conversation.