Level 28
You can access the session directly inside your view with
session()->get('something')
It's a global helper and works there too.
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
How to share session data accross views?
Say I have a session key with some data, in a controller I'd get it like so:
$session = $request->session()->get('someSessionValue');
And then pass it on to the view, fair enough.
And if I wanted to share some non session data accross all views, in AppServiceProvider I'd do e.g.:
public function boot()
{
$logo = \App\Misc::where('name', 'logo')->value('content');
View::share('logo', $logo);
}
But I cannot do that with session data, is it possible?
You can access the session directly inside your view with
session()->get('something')
It's a global helper and works there too.
Please or to participate in this conversation.