Search code examples
phppasswordsprotector

I need to show logged user's name


I am using this webpage password protector

It's working fine but i want to make the logged user's name appears in the protected page after logging in successfully. May you please help me ?


Solution

  • Modify this part of your code:

      else {
        // set cookie if password was validated
        setcookie("verify", md5($login.'%'.$pass), $timeout, '/');
    
        // Some programs (like Form1 Bilder) check $_POST array to see if parameters passed
        // So need to clear password protector variables
        unset($_POST['access_login']);
        unset($_POST['access_password']);
        unset($_POST['Submit']);
      }
    

    to read as:

      else {
        // set cookie if password was validated
        setcookie("verify", md5($login.'%'.$pass), $timeout, '/');
    
        echo "Username: " . $login;
    
        // Some programs (like Form1 Bilder) check $_POST array to see if parameters passed
        // So need to clear password protector variables
        unset($_POST['access_login']);
        unset($_POST['access_password']);
        unset($_POST['Submit']);
      }