Is there any way available to access Session values in AppServiceProvider
? I would like to share session value globally in all views.
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
The following works for me on Laravel 5.2, is it causing errors on your app?
AppServiceProvider.php
home.blade.php
Shows "en_US" in the browser.
You can't read session directly from a service provider: in Laravel the session is handled by
StartSession
middleware that executes after all the service providers boot phaseIf you want to share a session variable with all view, you can use a view composer from your service provider:
The callback passed as the second argument to the composer will be called when the view will be rendered, so the
StartSession
will be already executed at that point