Support the ongoing development of Laravel.io →
Authentication Session

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

Last updated 2 years ago.
0

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
0

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

Last updated 10 years ago.
0

Thanks , after i checking in my model i used for auth , i found the source problem in there and i already fix.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

zquilong zquilong Joined 11 Jan 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.