2015-10-20 107 views
7

使用Laravel 5登錄無法與Edge和Internet Explorer一起使用,而在其他瀏覽器中工作得非常好。Laravel登錄不能在邊緣和Internet Explorer中工作

我們懷疑它與會話未正確存儲有關,但說實話,我們不知道是什麼原因導致此問題。

當我們用適當的細節登錄時,登錄邏輯被激發並正確完成,但之後它剛剛重定向回登錄頁面,因此中間件可能認爲用戶未登錄並返回它們到登錄頁面,這就是我們認爲與會話有關的原因。

這是我們的登錄腳本:

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

什麼是你的錯誤\問題?更好地理解究竟發生了什麼將是有用的。 –

+0

多數民衆贊成在有趣的部分,瀏覽器似乎重新加載登錄頁面,而我們確保登錄邏輯執行! – Moodles

+0

看看[這個問題](http://stackoverflow.com/questions/17297990/why-would-laravel-sessions-fail-in-just-safari-and-ie-after-switching-server)。可能會爲您節省一些燈光 –

回答

1

這個問題似乎涉及到谷歌Analytics(分析),我們在邊緣和互聯網爆炸物移除Analytics(分析)腳本,現在一切似乎很好地工作......

3

更改cookie名稱以除去爲我工作的_(下劃線)。

app/config/session.php改變

'cookie' => 'laravel_session'

'cookie' => 'laravelsession'

+0

! –

+0

這也解決了我的問題。奇。 –

0

萬一它有助於任何人,我最近有一個非常類似的問題。事實證明,我在同一個域中有兩個Web應用程序共享相同的會話cookie名稱,而有些瀏覽器正在發送正確的cookie(純粹是因爲我猜想),IE並不是。

這個課?隨時更改默認laravel_session cookie名稱:)

這篇文章證明是有用的...... How to handle multiple cookies with the same name?

相關問題