Blogger Information
Blog 91
fans 2
comment 4
visits 128187
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
tp5定义常用函数
夏日的烈风的博客
Original
1934 people have browsed it

/**
 *  获取用户登录状态
 */
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;
        }
    }

 

 

 

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post