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