【问题标题】:Implementing Remember Me function in Laravel 4 returns an error在 Laravel 4 中实现 Remember Me 函数会返回错误
【发布时间】:2014-05-17 20:52:56
【问题描述】:

我正在尝试使用 Laravel 4 实现 Remember Me 函数。

但是我收到了这个错误:

Symfony\Component\Debug\Exception\FatalErrorException 语法

错误,意外的','

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';
    }

  }
}

编辑

Symfony\Component\Debug\Exception\FatalErrorException

…/app/controllers/UserController.php13

Illuminate\Exception\Handler 句柄关闭 0

第 13 行是

if(Auth::attempt($credentials), $remember)

【问题讨论】:

  • 请发布准确的错误消息,其中包含行号和导致错误的行。
  • @edvinas.me :请检查我所做的编辑。

标签: php authentication laravel controller laravel-4


【解决方案1】:

改变这一行

if (Auth::attempt($credentials), $remember) {

if (Auth::attempt($credentials, $remember)) {

Auth::attempt() 的右括号放错了位置。现在它应该可以工作了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-29
    • 2012-04-21
    • 2014-02-21
    • 2011-04-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多