October CMS resources and help articles

Simple and to the point. Optimized by the community.

Make session available in middleware

by Jacob, last modified on April 13th, 2021

To make the session context available in a middleware, you have to push the middleware to the Router instead of the Kernel and add it to the web group.

public function boot(): void
    /** @var \Illuminate\Routing\Router $router */
    $router = $this->app->make(\Illuminate\Routing\Router::class);
    $router->pushMiddlewareToGroup('web', YourMiddleware::class);



We use cookies to measure the performance of this website. Do you want to accept these cookies?