Reputation: 2655
I'm trying to implement a Remember Me
function using Laravel 4.
But I'm getting this error:
Symfony \ Component \ Debug \ Exception \ FatalErrorException syntax
error, unexpected ','
Routes.php
Route::get('/', function()
{
if(Auth::guest())
{
return View::make('login');
}
else
{
return View::make('index');
}
});
Route::post('/', 'UserController@Login');
UserController.php
class UserController extends BaseController {
public function Login() {
$credentials = array(
'username' => Input::get('username'),
'password' => Input::get('password')
);
$remember = Input::has('remember-me') ? true : false;
if (Auth::attempt($credentials), $remember) {
return Redirect::to('/');
}
else {
return 'fail';
}
}
}
EDIT
Symfony\Component\Debug\Exception\FatalErrorException
…/app/controllers/UserController.php13
Illuminate\Exception\Handler handleShutdown <#unknown>0
Line 13 is
if(Auth::attempt($credentials), $remember)
Upvotes: 0
Views: 403
Reputation: 4580
Change this line
if (Auth::attempt($credentials), $remember) {
to
if (Auth::attempt($credentials, $remember)) {
The closing bracket for Auth::attempt()
was misplaced. Now it should work.
Upvotes: 1