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

t0berius's avatar

create middleware to check session

I've created a middleware:

<?php

namespace App\Http\Middleware;

use Closure;

class checkNewEntries
{
    public function handle($request, Closure $next)
    {
        //user is logged into
        if($request->session()->get('auth') == true){
            die("ohhh middleware");

        }
        return $next($request);
    }
}

I don't use the default laravel auth, since the app itself is very small. When I use this middleware and assign it the global middleware I get this error all the time:

RuntimeException in Request.php line 388:
Session store not set on request.

How to fix this? The main idea behind the middleware is to perform some action if the user is logged into BEFORE the request itself is processed.

0 likes
2 replies
Snapey's avatar

save yourself the hassle and use what taylor gifted you...

Please or to participate in this conversation.