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 controller?
HomeController.php
public function isauthorized(){
if (Auth::user()){
return View::make('home.basic')
->with('basic1', 'Authorized');
}else{
return View::make('home.basic')
->with('basic1', 'Not Authorized');
}
}
My login system is working and the session is always set when logged in. When I call the function Auth::user() in the View or in routes.php, it is succesfull. But when I call the function in the controller, it is false. Help please.
You need to use the Auth facade in the controller;
add this line just before class definition.
use Auth;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With