使用 Laravel 5 登录无法在 Edge 和 Internet Explorer 中使用,但在其他浏览器中可以正常工作。
我们怀疑这与未正确存储 session 有关,但老实说,我们不知道是什么原因导致了这个问题。
当我们使用正确的详细信息登录时,登录逻辑被触发并正确完成,但之后它只是重定向回登录页面,所以中间件很可能认为用户没有登录并将它们返回到登录页面,这就是我们认为与 session 有关的原因。
这是我们的登录脚本:
$rules = array('email' => 'required|email|min:3|max:60',
'password' => 'required|min:6|max:20');
$attributeNames = array(
'email' => strtolower(Lang::get('auth.email')),
'password' => strtolower(Lang::get('auth.password')),
);
$validator = Validator::make(Input::all(), $rules);
$validator->setAttributeNames($attributeNames);
if ($validator->fails()){ return Redirect::back()->withErrors($validator); die(); }
//Make an login attempt
$auth = Auth::attempt(array(
'email' => Input::get('email'),
'password' => Input::get('password'),
'role' => 'admin'
), false);
if(!$auth){
$auth2 = Auth::attempt(array(
'email' => Input::get('email'),
'password' => Input::get('password'),
'role' => 'user'
), false);
if(!$auth2){
return Redirect::back()->withErrors(Lang::get('auth.errorText'))->withInput(Input::all());
die();
}
}
//If user is not activated
if(Auth::User()->activated != 'OK'){
Auth::logout();
return Redirect::back()->withErrors(Lang::get('auth.notActivated'));
die();
}
if(Auth::User()->sms_verificatie == '1') {
$user = Auth::User();
$user->sms_ok = 0;
$user->save();
$sms_codes_verwijderen = UsersSMSLogin::where('id_cms_users','=',Auth::User()->id)->delete();
return Redirect::route('sms-verificatie');
die();
}
Session::forget('dashboard_werkgever');
return Redirect::route('dashboard');
最佳答案
更改 cookie 名称以删除 _(下划线)对我有用。
在 app/config/session.php
中更改
'cookie' => 'laravel_session'
到
'cookie' => 'laravelsession'
关于php - Laravel 登录在边缘和 Internet Explorer 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33240144/