多次刷新后或LARAVEL 5中的几分钟后会话消失

时间:2015-07-21 05:29:27

标签: php session laravel laravel-5 session-variables

正如标题所说,我的Session变量存在问题,我已经在登录时存储了详细信息。但是,在网站上进行了几次刷新或导航后,我丢失了所有的Session变量。

Session.php

'driver' => env('SESSION_DRIVER', 'file'), 
'lifetime' => 999, 
'expire_on_close' => false,

和我的身份验证控制器。

public function authenticate(){ 
 $username = Input::get('username'); 
 $password = Input::get('password');

if (Auth::attempt(['username' => $username, 'password' => $password])) {
    // Authentication passed...
    // Store user data
    $this->storeSessionData();
    return redirect('dashboard');   
}
else{
    return 
        redirect()->back()->with('message', array('username' => $username));
   }
}

public function storeSessionData(){
// Retrieves the authenticated user
$user = Auth::user();
// Set details to session.
Session::put('firstname', $user->first_name);
Session::put('lastname',  $user->last_name);
Session::put('usertype',  $user->user_type); 
Session::put('image',     $user->image);
Session::put('mac',       ServerAddress::MACADDRESS());
}

 public function logout(){
//Logs user out
Auth::logout();

//Clears history
Session::flush();

//redirect back to login
return redirect('login');
}

0 个答案:

没有答案