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

dbehterev's avatar

flash session error when redirecting to 404 page

Hello everybody. I have L5.3 installation. I made 404.blade.php in errors folder. In this blade I check errors like that:

@if (count($errors) > 0) ...

This construction works everywhere but when redirecting to 404 page I got error:

Undefined variable: errors

This error dissappear if in app/Http/Kernel.php in middleware array I add:

protected $middleware = [
        \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
        **\Illuminate\Session\Middleware\StartSession::class**,
        **\Illuminate\View\Middleware\ShareErrorsFromSession::class**,
    ];

But in this case flashing session not working - no errors at all. So I'm asking someone may you also encountered this problem and solved it. Thanks for any hints.

0 likes
0 replies

Please or to participate in this conversation.