<form id="55n5d"></form>
    <form id="55n5d"></form> <noframes id="55n5d">

    <em id="55n5d"><address id="55n5d"></address></em>

        <form id="55n5d"></form>

        php簡單的登錄登出

        php by 黃業興 at 2020-03-30

        今天用PHP做了一個登錄登出的功能

        登錄代碼

        if($_POST['password']=='xxxxx'){
                if (!session_id()) session_start();
                $_SESSION['password'] = 'xxxxxx';
                $this->getMessage("登錄成功!",'/');
            }else{
                $this->getMessage("密碼錯誤!",'/');
        }
        

        檢查代碼

        if (!session_id()) session_start();
                $userName = '';
                if(isset($_SESSION['password'])&&$_SESSION['password']=='xxxxx'){
                    $userName= array('id'=>'1','name'=>'admin');
                }
                if(!empty($userName)){
                    $GLOBALS['user'] = $userName;
                }
        

        登出代碼

        if (!session_id()) session_start();
                if(isset($_SESSION['password'])){
                    unset($_SESSION['password']);
                }
                $this->getMessage("登出成功!",'/xxxx');
        
        
        

        思路就是這樣根據$GLOBALS['user']的值是否為空來判斷用戶是否登錄。

        請關注我們微信公眾號:mw748219


        永久免费看A片无码网站宅男

          <form id="55n5d"></form>
          <form id="55n5d"></form> <noframes id="55n5d">

          <em id="55n5d"><address id="55n5d"></address></em>

              <form id="55n5d"></form>