I am using CakePHP 2.8.3 and trying to use this component into my controller but I am getting this error, Does anybody experienced same please help.
Fatal Error Error: Call to a member function header() on a non-object File: /mnt/hgfs/Projects/dev_kp/lib/Cake/Controller/Controller.php
Line: 779 Notice: If you want to customize this error message, createapp/View/Errors/fatal_error.ctp
//Controller
<?php
App::uses('AppController', 'Controller');
class UsersController extends AppController
{
public $name = 'Users';
public $components = array('UserAuth');
public $uses = array('User');
public function dashboard()
{
echo $this->UserAuth->ValidateUser();
}
}
?>
//Component
<?php
App::uses('Component', 'Controller');
class UserAuthComponent extends Component
{
public function ValidateUser()
{
if(isset($_SESSION["USER_VALIDATE"]))
{
if($_SESSION["USER_VALIDATE"] == TRUE)
return TRUE;
}
else
{
$direct = new AppController();
$direct->redirect(array('controller' => 'users', 'action' => 'login'));
}
}
}
?>