Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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');
like image 261
Moodles Avatar asked Oct 20 '15 15:10

Moodles


2 Answers

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

In app/config/session.php changed

'cookie' => 'laravel_session'

to

'cookie' => 'laravelsession'

like image 124
Telmo Marques Avatar answered Oct 19 '22 13:10

Telmo Marques


The problem seems to be related to Google Analytics, we removed the Analytics script in Edge and internet exploder, and now everything seems to work fine...

like image 37
Moodles Avatar answered Oct 19 '22 15:10

Moodles