Montag 23 Januar 2017 um 14:04

Resolving Laravel Session and Middleware Issues

Von 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.

Etiketten: coding, laravel


Bemerkungen

Anmeldung oder Registrieren einen Kommentar hinterlassen..


Archiv