/**
* 获取用户登录状态
*/
function IsLogin(){
$uid = \think\Session::get('user_id');
if($uid){
defined('UID') or define('UID',$uid);
}else{
defined('UID') or define('UID',0);
}
}
/**
* 获取管理员登录状态
*/
function IsAdminLogin(){
$admin_id = \think\Session::get('admin_id');
if($admin_id){
defined('ADMIN_UID') or define('ADMIN_UID',$admin_id);
}else{
defined('ADMIN_UID') or define('ADMIN_UID',0);
}
}
protected function _initialize()
{
parent::_initialize();
if (!Session::has('admin_id') && !Session::has('user_id')) {
$result = [
'error' => 1,
'message' => '未登录'
];
echo json_encode($result);exit;
}
}