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

Kaustubh's avatar

Storing session value to database

I stored value in session, but i want to store in database. I dont know how session is stored in database automatically

0 likes
2 replies
atishrajput's avatar

@Kaustubh

 1. create a sessions table


   Schema::create('sessions', function(Blueprint $table) {
        $table->increments('id');
        $table->text('payload');
        $table->integer('last_activity');
        $table->timestamps();
    });


 2. go to app\config\session.php

      change session "driver to database" 

      assign table name to table variable


 return array(
    'driver' => 'database',
    'lifetime' => 120,
    'expire_on_close' => false,
    'table' => 'sessions',
    'path' => '/',
  );
1 like

Please or to participate in this conversation.