When displaying HTTP error pages (404, 500 and so on), I want to keep the standard design of my current project, including header and footer. My project also includes a registration system. When a user is logged in and receives an error message, he will be redirected to the corresponding error page, but Laravel does not recognize that the user is logged in. That's because custom error pages (located in resources/views/errors/{code}.blade.php
don't run through the normal web middleware (for some reasons).
This behavior was already reported a few times, but no sufficient answer was provided. A hacky solution is to set the StartSession
middleware to be applied on every request, but this isn't sufficient in my case.
How can I use the Auth/Session middleware on custom error pages anyway?
StartSession
middleware (or any other) to every requestIn coherence with the discussion around the github issue I've opened, here are the two best practices:
StartSession
middleware to the global middleware list is a good pratice, as long as your app doesn't have an API or similarIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With