我一直在使用Sentinel在Laravel 5.2上实现一个简单的身份验证系统.
// Route : /login
$success = Sentinel::authenticate(array(
'email' => $email,
'password' => $password,
));
echo $success ? 'Login success' : 'Login failed';
Run Code Online (Sandbox Code Playgroud)
因此,上述代码Login success在验证码之后输出.但是,登录状态不会持久保存到其他请求.即:如果我从其他请求检查身份验证状态,则表示我没有登录!
// Route : test-login
echo \Sentinel::check() ? 'User is logged in' : 'User is not logged in';
Run Code Online (Sandbox Code Playgroud)
我甚至尝试过使用defaut laravel authencation \Auth::attempt.但是,这也给了同样的东西.
非常感谢任何帮助.