Php Laravel Auth::get()在重定向到页面后失败
我正在学习关于Laravel身份验证的教程,以进一步了解它。我已经到了不能再往前走的地步,因为我很困惑 问题的继续:我做了一次Auth::尝试,它可以工作,但一旦我重定向到一个页面,Auth::get()就不再工作了 这是我的控制器:Php Laravel Auth::get()在重定向到页面后失败,php,session,authentication,laravel,Php,Session,Authentication,Laravel,我正在学习关于Laravel身份验证的教程,以进一步了解它。我已经到了不能再往前走的地步,因为我很困惑 问题的继续:我做了一次Auth::尝试,它可以工作,但一旦我重定向到一个页面,Auth::get()就不再工作了 这是我的控制器: public function postSignIn() { $validator = Validator::make(Input::all(), array( 'usrUsername' => 'requ
public function postSignIn()
{
$validator = Validator::make(Input::all(),
array(
'usrUsername' => 'required'
,'usrPassword' => 'required'
));
if($validator->fails()){
return Redirect::route('account-sign-in-get')
->withErrors($validator)
->withInput();
}else{
$auth = Auth::attempt(array(
'usrUsername' => Input::get('usrUsername')
,'password' => Input::get('usrPassword')
,'usrIsActive' => 1
));
if($auth){
return Redirect::intended('/')
->with('global', 'Signed in. Have a great adventure!');
}else{
return Redirect::route('account-sign-in-get')
->with('global', 'Are you sure that is your correct username/password combination?');
}
}
}
这是我在navigation.blade.php上的html页面:
@if(Auth::check())
<li><a href="{{ URL::route('account-logout') }}">Sign Out</a></li>
@else
<li><a href="{{ URL::route('account-create-get') }}">Create account</a></li>
<li class="nav-divider"></li>
<li><a href="{{ URL::route('account-sign-in-get') }}"><i class="glyphicon glyphicon-off"></i> Sign In</a></li>
@endif
使用Auth::trunt()登录后,会话似乎没有持久化 在用户类(型号)中,尝试添加
$primaryKey = ''; // add your user table primary key here
Auth::loginUsingId(Auth::user()->userTablePrimaryKey);
然后,您的postSignIn()
函数,在if($auth){…}
中,在返回之前,尝试添加
$primaryKey = ''; // add your user table primary key here
Auth::loginUsingId(Auth::user()->userTablePrimaryKey);
使用Auth::trunt()登录后,会话似乎没有持久化 在用户类(型号)中,尝试添加
$primaryKey = ''; // add your user table primary key here
Auth::loginUsingId(Auth::user()->userTablePrimaryKey);
然后,您的postSignIn()
函数,在if($auth){…}
中,在返回之前,尝试添加
$primaryKey = ''; // add your user table primary key here
Auth::loginUsingId(Auth::user()->userTablePrimaryKey);
使用Auth::trunt()登录后,会话似乎没有持久化 在用户类(型号)中,尝试添加
$primaryKey = ''; // add your user table primary key here
Auth::loginUsingId(Auth::user()->userTablePrimaryKey);
然后,您的postSignIn()
函数,在if($auth){…}
中,在返回之前,尝试添加
$primaryKey = ''; // add your user table primary key here
Auth::loginUsingId(Auth::user()->userTablePrimaryKey);
使用Auth::trunt()登录后,会话似乎没有持久化 在用户类(型号)中,尝试添加
$primaryKey = ''; // add your user table primary key here
Auth::loginUsingId(Auth::user()->userTablePrimaryKey);
然后,您的postSignIn()
函数,在if($auth){…}
中,在返回之前,尝试添加
$primaryKey = ''; // add your user table primary key here
Auth::loginUsingId(Auth::user()->userTablePrimaryKey);
我想你是指
Auth::check()
,而不是Auth::get()
?是的,这是正确的。我会编辑文本,这样就可以了。谢谢你。我想你是指Auth::check()
,而不是Auth::get()
?是的,这是正确的。我会编辑文本,这样就可以了。谢谢你。我想你是指Auth::check()
,而不是Auth::get()
?是的,这是正确的。我会编辑文本,这样就可以了。谢谢你。我想你是指Auth::check()
,而不是Auth::get()
?是的,这是正确的。我会编辑文本,这样就可以了。谢谢你。我会尽快尝试的。非常感谢您的见解。为什么教程中没有提到这一点?(我正在使用composer的脚手架上的默认代码)我会尽快尝试Raffy Cortez。非常感谢您的见解。为什么教程中没有提到这一点?(我正在使用composer的脚手架上的默认代码)我会尽快尝试Raffy Cortez。非常感谢您的见解。为什么教程中没有提到这一点?(我正在使用composer的脚手架上的默认代码)我会尽快尝试Raffy Cortez。非常感谢您的见解。为什么教程中没有提到这一点?(我使用composer的脚手架上的默认代码)