i am using Cakephp1.3 and i am trying to set value in app_controller.php under beforeFilter Function here is my Code.
function beforeFilter() {
$sess = $this->Session->read();
if(isset($sess['Auth']['User'])) {
$checkLogin = 1;
}
else { $checkLogin=0; }
$this->set('checkLogin',$checkLogin);
//$this->Auth->authorize = 'actions';
$this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
$this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'index');
$this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'login');
}
Now i want to Access Checklogin value in user_controller.php
i tried this
function beforeFilter() {
parent::beforeFilter();
echo $checkLogin; exit;
$this->Auth->allow(array('users' => 'login'));
$this->Auth->authorize = 'controller';
}
i got this error
undefined variable::checklogin()
Please tell me solution for this
Thanks in advance
You cannot access
checkLoginunless you make it a global variable.Check variable scopein PHP.