Laravel4:记住身份验证

After login by a user, the authentication should be rembered and Auth::check() should return true. But on the user profile it returns false. What's wrong or missing?

Route::post('login', function() {
            $userdata = array(
                'username' => Input::get('user'),
                'password' => Input::get('pw')
            );
            if (Auth::attempt($userdata, true)) {
                return Redirect::to('profile');
            } else {
                return Redirect::to('/')->with('login_errors', true);
            }
        });

Route::get('profile', function() {
            return (Auth::check() ? 'logged in' : 'not logged in') . '<br />' .
                    (Auth::user()==null ? 'null' : Auth::user()->name);
        });
Route::get('profile', function() {
        return (Auth::check() ? 'logged in' : 'not logged in') . '<br />' .
                (Auth::user()==null ? 'null' : Auth::user()->name);
    });

I think your problems lies in this. Ternary operator use should look like $action = (empty(var)) ? 'default' : null;

Route::get('profile', function() {
        return (Auth::check()) ? 'logged in' : 'not logged in') . '<br />' .
                (Auth::user()==null) ? 'null' : Auth::user()->name);
    });