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

d3xt3r's avatar
Level 29

Weird behaviour of Session Middleware

When i attach the web middleware in my route group as below, the session is created, cookies set and session data is saved to database.

Route::group( [
        'https',
    'middleware' => ['web'],
    ], function(){
    ....
});

However, when I attach the middleware in controller constructor, the session is started, cookies set but the session data is not persisted.

public function __construct()
    {
        $this->middleware('web');
    }

Any one has any clue what going on?

0 likes
1 reply
d3xt3r's avatar
d3xt3r
OP
Best Answer
Level 29

Well this is because controller middleware(s) are not terminable. :(

Please or to participate in this conversation.