Good afternoon , all i have some trouble with login i dont know why login only work in post page when i go to different page state is not logged anymore , after i searching i understand that because sessions is be refreshed
but , i dont have clue how to fix it
there are some code i use in controller for login post
$userlogin = [
'Staff_id' => Input::get('staff_id'),
'password' => Input::get('password')
];
$auth = Auth::attempt($userlogin );
if($auth)
{
Session::put('user', Auth::user());
$user = User::find($_POST['staff_id']);
Auth::login(Auth::user());
return View::make('home');
}else{
return Redirect::route('log-in')
->with('msg', 'Login failed , no Account found!')
->withInput();
}
these are my session config
'driver' => 'native',
'lifetime' => 120,
'expire_on_close' => true,
can someone help me , sorry if this question already being ask by other
this is how i check login or not
@if(Auth::user())
<p>Welcome {{ Auth::user()->Staff_id;}} </p>
</br>
@include('Component.logout')
</br>
@else
<P>not login yet</P>
@endif
try this code
$userlogin = [
'Staff_id' => Input::get('staff_id'),
'password' => Input::get('password')
];
if (Auth::attempt($userlogin)) {
return View::make('home')
} else {
return Redirect::route('log-in');
->with('msg', 'Login failed , no Account found!')
->withInput();
}
make sure that the columns in the user table named "Staff_id" and "password". You don't need to save the authentification in a session var... you can always use \Auth::XXX e.g. \Auth::check() or \Auth::user-()>Staff_id
Thanks , after i checking in my model i used for auth , i found the source problem in there and i already fix.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community