2016-05-29 3 views
0

Я пробую простую форму входа в laravel с классом Auth, что я замечаю, так это то, что он регистрируется мной, даже если я закрою браузер или перезагрузите компьютер. Мне нужен логин, который позволяет мне войти в систему, только когда вкладка открыта. Как я могу это сделать? Код от контроллера:Laravel 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

В config/session.php установлен expire_on_close к true.

/* 
|-------------------------------------------------------------------------- 
| 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

изменение config/session.php

'expire_on_close' => false, 

в

'expire_on_close' => true, 
Смежные вопросы