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

Ulimn's avatar

Session variable empty in Service Provider

I'm trying to share a Session value with all views using AppServiceProvider class.

In the boot() function I said: view()->share('key', Session::get('key'));

But, the value is null. What can be the problem? In the Controller I'm setting it, it works fine. Even after removing the Session::put() line, the value is still in the session (obviously).

0 likes
0 replies

Please or to participate in this conversation.