Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/250.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel Auth::get()在重定向到页面后失败_Php_Session_Authentication_Laravel - Fatal编程技术网

Php Laravel 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

我正在学习关于Laravel身份验证的教程,以进一步了解它。我已经到了不能再往前走的地步,因为我很困惑

问题的继续:我做了一次Auth::尝试,它可以工作,但一旦我重定向到一个页面,Auth::get()就不再工作了

这是我的控制器:

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的脚手架上的默认代码)