亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Home php教程 php手冊 Determine whether the user is logged in (jump to different pages or perform different actions)

Determine whether the user is logged in (jump to different pages or perform different actions)

Sep 23, 2016 am 03:30 AM

1.

2.

   <span style="color: #0000ff;"><</span><span style="color: #800000;">if </span><span style="color: #ff0000;">condition</span><span style="color: #0000ff;">="$GLOBALS['userinfo']['user_id'] gt 0"</span><span style="color: #0000ff;">></span>
        <span style="color: #0000ff;"><</span><span style="color: #800000;">span </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="help_wz"</span><span style="color: #0000ff;">><</span><span style="color: #800000;">a </span><span style="color: #ff0000;">href</span><span style="color: #0000ff;">="{$Think.config.VIP_URL}/Member/user_pwd/"</span><span style="color: #ff0000;"> style</span><span style="color: #0000ff;">="color:#404958;"</span><span style="color: #0000ff;">></span>找回登錄密碼<span style="color: #0000ff;"></</span><span style="color: #800000;">a</span><span style="color: #0000ff;">></</span><span style="color: #800000;">span</span><span style="color: #0000ff;">></span>
        <span style="color: #0000ff;"><</span><span style="color: #800000;">else</span><span style="color: #0000ff;">/></span>
        <span style="color: #0000ff;"><</span><span style="color: #800000;">span </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="help_wz"</span><span style="color: #0000ff;">><</span><span style="color: #800000;">a </span><span style="color: #ff0000;">href</span><span style="color: #0000ff;">="/Login/FindPwd"</span><span style="color: #ff0000;"> style</span><span style="color: #0000ff;">="color:#404958;"</span><span style="color: #0000ff;">></span>找回登錄密碼<span style="color: #0000ff;"></</span><span style="color: #800000;">a</span><span style="color: #0000ff;">></</span><span style="color: #800000;">span</span><span style="color: #0000ff;">></span>
        <span style="color: #0000ff;"></</span><span style="color: #800000;">if</span><span style="color: #0000ff;">></span>

3. Set global variables in the background and query user information

<span style="color: #000000;">    public function UserInfo($user_id){
        //查詢系統(tǒng)信息
        $system=array(
                'CmdId'=>'System',
                'Token'=>'wap',
                'PostDetails'=>json_encode(array(
                )));
        //通過curl的post方式發(fā)送接口請求
        $curl=new CurlController();
        $strs=$curl->SendCurl($system);
        $GLOBALS['system']=$strs['AcctDetails'];
        if(empty($user_id)){
            return false;
        }
        setcookie("login_uid", $user_id, time() + 3600, "/", C('cookie_url'));
        setcookie("rdun", $this->authcode($user_id . "," . time(), "ENCODE"), time() + 3600,"/",C('cookie_url'));;
        $data=array(
                'CmdId'=>'Individual',
                'Token'=>session('token'),
                'PostDetails'=>json_encode(array(
                        'user_id'=>$user_id,
                )));
        //通過curl的post方式發(fā)送接口請求
        $curl=new CurlController();
        $str=$curl->SendCurl($data);
        
        $GLOBALS['userinfo']=$str['AcctDetails'];
        $newtoken=unserialize($str['AcctDetails']['token']);
        $oldtoken=unserialize(session('token'));
        if(!empty(session('token')) && !empty($str['AcctDetails']['token'])){
            //用戶不對
            if($newtoken['user_id'] !== $newtoken['user_id']){
                session('token',null);
                session('user_id',null);
                header('Location:/Login/Login');
                return false;
            }
            //token不對
            if($newtoken['time'] !== $oldtoken['time']){
                session('token',null);
                session('user_id',null);
                header('Location:/Login/Login');
                return false;
            }
            //超時的不能在這做,原因是存入session的值不變,如果用戶一直操作的話,而且只登陸一次,那么就會出現(xiàn)問題
        }
        return true;
    }</span>

4. Call this method in the background

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1488
72