Support the ongoing development of Laravel.io →
Authentication
Last updated 2 years ago.
0

I don't know if you created the variables in your file like

$user = Input::get('username'); // usuario
$password= Input::get('password'); // password

if you didn't do it or do like so

$credentials = array(
    'username'	=> Input::get('username'),
    'password'	=> Input::get('password')
);

if ( Auth::attempt($credentials) ) {
    //
}
Last updated 2 years ago.
0

In the Auth::attemp, i dont have a problem. it works.

[code] public function doLogin() { $user = Input::get('txtUser'); $password = Input::get('txtPassword'); if (Auth::attempt(array('username' => $user, 'password' => $password))) { return Redirect::intended('dashboard'); } return Redirect::back(); } [/code]

in the routes.php i have the next code: [code] Route::get('dashboard',function(){ if (Auth::guest()){ echo "Guest"; }else{ echo "Go....."; } }); [/code]

and always Auth::guest() is true!!!.

I guess, after login, laravel create a different session.

Last updated 2 years ago.
0

What does

Route::get('dashboard', function(){
    if ( ! Auth::check() ) {
        return "Not logged in";
    } 

    return Auth::user()->id;
});

return ?

Last updated 2 years ago.
0

thankyou for your time eriktisme.

In windows works without problem, your code and my code works. But doesn't work in Linux, my production server.

My code is below:


Route::post('login', function(){
	if(Auth::attempt(array('user' => 'myuser', 'password' => 'mypassword'), true)){
		echo "OK";
	}else{
		echo "Error";
	}
	echo (Auth::check()) ? 'Logged in' : 'Not logged in';
	return Redirect::to("dashboard");
});


Route::get('dashboard',function(){
	echo (Auth::check()) ? 'Logged in' : 'Not logged in';
        //in windows, return Logged in, but in mac or linux, return Not logged in.
});

Last updated 2 years ago.
0

Then I can't help your further it must be in the system as the code is correct then.

Last updated 2 years ago.
0

somebody help me???

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

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.

© 2024 Laravel.io - All rights reserved.