go back to the original problem. why would you need to start session again when it is already started in the web middleware group?
list your routes and check what middleware is being applied to each. Make sure nothing is applied twice
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am using Laravel 10.
Earlier I encountered error "Session store not set on request."
By adding this \Illuminate\Session\Middleware\StartSession::class, in protected middleware The issue was resolved.
protected $middleware = [
\Illuminate\Session\Middleware\StartSession::class,
\App\Http\Middleware\LogUserActivity::class,
];
But after adding this Session is expiring within 2 or 3 seconds.
My session.php
'driver' => env('SESSION_DRIVER', 'database'),
'lifetime' => env('SESSION_LIFETIME', 120),
'expire_on_close' => false,
.env
SESSION_DRIVER=database
SESSION_LIFETIME=120
Table sessions
Column Type Comment
id | character varying(255)
user_id | uuid NULL
ip_address | character varying(45) NULL
user_agent | text NULL
payload | text
last_activity | integer
Please or to participate in this conversation.