Manula Thantriwatte Manula Thantriwatte - 4 months ago 26
PHP Question

How to get Sentinel logged user to front-end

I want to get the sentinel logged user to front-end. In my front-end blade PHP I used

method. But it
return false
. When I check the same condition in the controller class it
return true
. So I want to find out how to get the logged user to front-end.


You can get the logged user to all the front-end pages by adding following line of code to boot method in AppServiceProvider.php class.

view()->share( 'loggedUser', Sentinel::getUser() );

After that you can access the Sentinel user from the loggedUser variable in all the front-end classes. Form it you can access all the Sentinel::getUser() related methods from the front-end.