我開始與我的項目使用laravel 5一起工作。我意識到,它在我登錄到我的網站後與會話在本地目錄中工作正常,但我只知道當我將我的項目託管到服務器時出現問題。每次登錄後,會話都會記不起來,並且每次借用該頁面時都會重新創建。這給我帶來了問題。會話不記得,爲什麼會在每次加載頁面時創建會話?
Laravel登錄
public function postLogin(){
$hit = 0;
if(Request::ajax()){
$pw = Request::input('pw');
if(!empty($pw)){
$admin_pass = AdminPassword::first(['admin_pass']);
$ip_address = Request::ip();
if(!empty($admin_pass) && trim($admin_pass->admin_pass) == trim($pw)){
if(Auth::attempt(['username' => Request::input('username'), 'password' => Request::input('password'),'status'=>1])){
try{
$user = Auth::user();
$user->last_login = date('Y-m-d H:i:s');
$user->login_ip = $ip_address;
$user->save();
$permissions = Auth::user()->permission;
if(!empty($permissions) && count($permissions) >0){
session(['ROLE_PERMISSION'=>$permissions]);
}
$failed = FailedLogin::whereRaw('ip_address = INET_ATON(\''.$ip_address.'\')')->first();
if(!empty($failed)){
$failed->delete();
}
}catch (\Exception $ex){}
$url = Request::session()->pull('url.intended', '/');
return ['url'=>$url,'msg'=>'Successfully.','status'=>true,'hit'=>$hit];
}else{
$hit = $this->updateFailedLogin($ip_address,Request::input('username'));
}
}else{
$hit = $this->updateFailedLogin($ip_address,Request::input('username'));
}
}
}else{
return redirect()->route('login');
}
return ['url'=>'','msg'=>'Try again.','status'=>false,'hit'=>$hit];
}
請幫助我。這是我的項目的最後一步。
謝謝您的高級。
在你的.env文件中,你有什麼'SESSION_DRIVER'設置爲? – BrynJ