Use PHP to detect which htaccess user signed in?

后端 未结 6 1132
盖世英雄少女心
盖世英雄少女心 2020-12-15 17:24

I\'m constructing an upload so people I know can send me files securely, and with ease. But I want to design it just so, that when one of my friends sign in with their

相关标签:
6条回答
  • 2020-12-15 18:02

    You'd want $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW'] to retrieve the username and password, assuming you mean a regular "basic authentication" login, as done by Require valid-user settings in .htaccess.

    more details here.

    0 讨论(0)
  • 2020-12-15 18:07

    Not to open up an old task, but running PHP 5 with Apache 2.2 and this is the variable that works for me:

    $_SERVER['USER'];
    
    0 讨论(0)
  • 2020-12-15 18:11

    Something that worked for me:

    $_SERVER['REDIRECT_REMOTE_USER']
    

    Please try the above. In general, one can do "print_r($_SERVER)" and hunt out the parameter one is looking for.

    0 讨论(0)
  • 2020-12-15 18:11

    I think the following variables give you the derise information:

    PHP_AUTH_USER: When doing HTTP authentication this variable is set to the username provided by the user.

    PHP_AUTH_PW: When doing HTTP authentication this variable is set to the password provided by the user.

     echo "<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>";
     echo "<p>You entered {$_SERVER['PHP_AUTH_PW']} as your password.</p>";
    
    0 讨论(0)
  • 2020-12-15 18:14

    You can read it from $_SERVER['PHP_AUTH_USER']

    0 讨论(0)
  • 2020-12-15 18:16

    You should be able to get the user name the user signed in with from the $_SERVER['REMOTE_USER'] variable after they've successfully signed in.

    0 讨论(0)
提交回复
热议问题