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

Devops_Guru's avatar

How to configure Session using DB to store session.

I have created a session table using the php artisan session:table command and created auth using php artisan make:auth.

I want to use the Database to store my session. I tried creating sessionModel. No Luck.

I am confused in how sessions work. Anyone with working setup for session using DB table will be appreciated.

Thanks in advance.

0 likes
4 replies
Snapey's avatar

have you changed session storage in config/session.php ?

Devops_Guru's avatar

yes i have changed the storage to database. I have a table session in my database, i created the table using php artisan session:table and php artisan migrate .

In my config/session.php i have

'driver' => env('SESSION_DRIVER', 'database'),

The problem is My session table is always empty, no records are added, even the 'id' or 'user_id' are not being updated.

vipin93's avatar
vipin93
Best Answer
Level 13

change your .env file SESSION_DRIVER=database

6 likes
Devops_Guru's avatar

Thanks @vipin93

It was a rookie mistake. I haven't noticed that ENV file also has session driver details.

Thanks. It works like a charm.

Please or to participate in this conversation.