echo $rule;
static $Auth = null;
if (!$Auth) {
$Auth = new \Think\Auth();
}
if(!$Auth->check($rule,$_SESSION['uid'])){
echo '你没有权限';
}
就每一个模块都提示我没有权限呢? 我明明已经给他权限了啊
if(!IS_POST) {
redirect(U('index'));
}
$db = M('admin');
$account = I('account');
$password = I('password','','md5');
$where = array('account'=>$account,'password'=>$password);
$field = array('nickname','uid');
$user = $db ->where($where)->field($field)->find();
if(!$user) {
$this->error('帐号或密码错误');
}
}
//写入session
$_SESSION['uid'] = $user['uid'];
$_SESSION['nickname'] = $user['nickname'];
redirect(U('Index/index'));common控制器 代码 if(!isset($_SESSION['uid'])) {
redirect(U('Login/index'));
}
// 检测当前页是否有权限访问 // ' admin/index/index'
$rule = strtolower(MODULE_NAME.'/'.CONTROLLER_NAME.'/'.ACTION_NAME);
//$rule = 'Home/Index/index';
echo $rule;
p(M('auth_rule')->select());
$Auth = new \Think\Auth();
if(!$Auth->check($rule,$_SESSION['uid'])){
echo '没有权限';
}
最佳答案