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) ) {
//
}
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.
What does
Route::get('dashboard', function(){
if ( ! Auth::check() ) {
return "Not logged in";
}
return Auth::user()->id;
});
return ?
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.
});
Then I can't help your further it must be in the system as the code is correct then.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community