Laravel framework- Why aren\'t I able to use Auth::user(), (to see if user has been logged in) in the controller of the laravel project. Is the Session not connected to the cont
I have the same problem. The solution I've found, is to not use \Auth::user() (it returns null). Instead, go through the guard like this: \Auth::guard('mrm')->User()
. Obviously replace 'mrm' with whatever auth guard you are using.
This works, correctly returning the current user even when Auth::User returns null, and you can also use other methods on it - e.g. \Auth::guard('mrm')->check()
instead of \Auth::check()
(which always returns false).
No idea why the Auth facade doesn't work, but at least there is an alternative that does.