2016-05-29 12 views
0

laravelでAuthクラスの簡単なログインフォームを試していますが、ブラウザを閉じたりコンピュータを再起動してもログインしていることに気付いています。私は、タブが開いている間だけ私をログインさせ続けるログインをしたい。どうやってやるの? コントローラからコード:config/session.phpLaravel 5にログインしています

public function doLogin() 
{ 

$rules = array(
'username' => 'required', 
'password' => 'required|alphaNum|min:3' // password can only be  alphanumeric and has to be greater than 3 characters 
); 

// run the validation rules on the inputs from the form 
$validator = Validator::make(Input::all(), $rules); 

// if the validator fails, redirect back to the form 
if ($validator->fails()) { 
return Redirect::to('login') 
    ->withErrors($validator) // send back all errors to the login form 
    ->withInput(Input::except('password')); // send back the input  (not the password) so that we can repopulate the form 
} else { 

// create our user data for the authentication 
$userdata = array(
    'username'  => Input::get('username'), 
    'password' => Input::get('password') 
); 

// attempt to do the login 
if (Auth::attempt($userdata)) { 

    // validation successful! 
    // redirect them to the secure section or whatever 
    // return Redirect::to('secure'); 
    // for now we'll just echo success (even though echoing in a controller is bad) 
    return Redirect::to('user'); 

} else {   

    // validation not successful, send back to form 
    echo "username ose pass gabim"; 

} 

} 

} 

答えて

0

trueexpire_on_closeを設定しました。

/* 
|-------------------------------------------------------------------------- 
| Session Lifetime 
|-------------------------------------------------------------------------- 
| 
| Here you may specify the number of minutes that you wish the session 
| to be allowed to remain idle before it expires. If you want them 
| to immediately expire on the browser closing, set that option. 
| 
*/ 

'lifetime' => 120, 

'expire_on_close' => false, 
0

'expire_on_close' => true, 
から config/session.php

'expire_on_close' => false, 

の変化

関連する問題