Laravel login not working in edge and internet explorer

Login with Laravel 5 is not working with Edge and Internet Explorer, while working perfectly fine in other browsers.

We suspect it has something to do with the sessions not being properly stored but to be honest we have no idea what causes this problem.

When we login in with proper details, the login logic is fired and completed properly, but after that its just redirected back to the login page, so is likely that the middleware thinks that the user is not logged in and returns them to the login page, that is why we think is has something to do with the sessions.

This is our login script:

    $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');

Changing the cookie name to remove the _ (underscore) worked for me.

In app/config/session.php changed

'cookie' => 'laravel_session'

to

'cookie' => 'laravelsession'


这个问题似乎与谷歌分析有关,我们删除了边缘和互联网爆炸案中的分析脚本,现在一切似乎都正常......


Just in case it helps anyone, I've recently had a very similar issue. It turns out I had two web applications on the same domain sharing the same session cookie name and while some browsers were sending the right cookie (by sheer luck I suppose), IE wasn't.

Lesson from this? Always change the default laravel_session cookie name :)

This post proved useful... How to handle multiple cookies with the same name?

链接地址: http://www.djcxy.com/p/88352.html

上一篇: Windows服务不能从Windows 10升级开始

下一篇: Laravel登录不能在边缘和Internet Explorer中工作