I have an auth problem with laravel sessions. (He worked on the same system before)
This is my user controller
public function postLogin()
{
$username = Input::get("username");
$password = Input::get("password");
$credentials = array
(
"username"=> $username,
"password" => $password,
);
if (Auth::attempt($credentials))
{
echo Auth::user()->username;
exit();
}
else
{
return Redirect::to("user/login")->with("error_msg","Giriş Başarısız! <br>Lütfen girdiğiniz bilgileri kontrol edip yeniden deneyin.");
}
}
It returns the username .. But when I redirect the page session, it gets lost.
public function postLogin()
{
$username = Input::get("username");
$password = Input::get("password");
$credentials = array
(
"username"=> $username,
"password" => $password,
);
if (Auth::attempt($credentials))
{
return Redirect::to('check_login');
}
else
{
return Redirect::to("user/login")->with("error_msg","Giriş Başarısız! <br>Lütfen girdiğiniz bilgileri kontrol edip yeniden deneyin.");
}
}
And my route:
Route::get("check_login",function(){
echo Auth::user()->username;
});
Result:
ErrorException
Trying to get property of non-object
echo Auth::user()->username;
source
share