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

mtctonyhkhk2010's avatar

Session store not set on request when accessing 404 page after laravel upgrade

I recently updated my website to laravel 5.3, everything work fine except one thing. When I try to access a page that should not exist. It will give me a 'Session store not set on request.' error in Illuminate\Http\Request.php line 905. Before I upgrade, my website redirected correctly to the 404 page. Anybody know why?

0 likes
4 replies
geowrgetudor's avatar

Can you post a code sample where are you using sessions? I think you are using sessions in __construct() method

1 like
pavelpage's avatar

Has the same problem. Does anybody know the solution? I just can add that for me this problem is connected with the url for non-existing files. And also the exception is throwed, only if the blade contain helper functions like "old('key')".

faniuta's avatar

To avoid problems when you have other exception or recive request with api middleware,change the render function In App/Exceptions/Handler.php to :

public function render ($request, Exception $exception)
{
    if ($this->isHttpException($exception)) {
        switch ($exception->getStatusCode()) {
            case '404':
                \Route::any(request()->path(), function () use ($exception, $request) {
                    return parent::render($request, $exception);
                })->middleware('web');
                return app()->make(Kernel::class)->handle($request);
                break;
            default:
                return $this->renderHttpException($exception);
                break;
        }
    } else {

        return parent::render($request, $exception);
    }
}

Please or to participate in this conversation.