【发布时间】:2011-11-04 07:06:45
【问题描述】:
我正在使用 Cakephp1.3,我正在尝试在 beforeFilter 函数下的 app_controller.php 中设置值,这是我的代码。
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');
}
现在我想访问 user_controller.php 中的 Checklogin 值
我试过了
function beforeFilter() {
parent::beforeFilter();
echo $checkLogin; exit;
$this->Auth->allow(array('users' => 'login'));
$this->Auth->authorize = 'controller';
}
我收到了这个错误
未定义变量::checklogin()
请告诉我解决方法
提前致谢
【问题讨论】: