lundi 23 janvier 2017 à 14:04

Resolving Laravel Session and Middleware Issues

Par Eric Antoine Scuccimarra

I figured out how to resolve the session and middleware issues I mentioned in the previous post. I previously had the middleware in the $middleware array in /app/Http/Kernel.php. The Laravel session is started with the middleware StartSession, which is in the $middlewareGroups array under web. I moved my middleware to the web $middlewareGroups and put it after StartSession, and now the Middleware can access the session. The only difference is that the Middleware will only be run on requests that are part of the 'web' group instead of on every request, but this actually makes more sense in this case.

After having figured this out the unexpected behavior I was witnessing before makes sense now.

Libellés: coding, laravel


Commentaires

Connectez-vous ou Inscrivez-vous pour enregistrer un commentaire..


Archives du Blogue