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

stephan-v's avatar

Laravel sessionhandler

It looks like Laravel uses it's own implementation of a session instead of the session superglobal. The session is started and saved from the session middleware.

One thing the session superglobal does do though it implement a shutdown handler that always triggers a session to be stored. With Laravel's implementation this functionality seems to be lost.

This would probably mean that if something were to go wrong inside a controller you would not reach the middleware's save method.

It seems a shame to let to functionality go. I am hoping somebody could prove me wrong here and let me know if session still do get saved by maybe an errorhandler or something. But as of yet I have not found something like that in the codebase yet.

Does Laravel really not save the session when something goes wrong in the controller or is there a fallback in the codebase somewhere?

Cheers.

0 likes
0 replies

Please or to participate in this conversation.