Add the following code in the bootstrap/app.php file:
use Illuminate\Session\Middleware\StartSession;
$middleware->append(StartSession::class);
This is because the way we register custom middleware has changed slightly compared to Laravel 10 and earlier versions.
Hope this helps, thank you!
Top comments (7)
Thank you for this
Thank you HUGE much :-)
thanks
This saved my life, thanks so much.
Thank you very much
That is wrong, by doing this you restart the session on each request, so for exemple flash message won't work anymore.
Correct method is to append your middleware to the Web Middleware :
спасибо тебе