.htaccess & .htpasswd

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Otto

    .htaccess & .htpasswd

    Hello to all,

    I have protected a directory with the help of .htaccess &
    htpasswd.

    I also read that I can get the login value in a php
    variable.

    Like this:
    $user = $_SERVER['PHP_AUTH_USER'];
    echo "User : ";
    echo $user;

    I did it, but nothing is displayed after the echo User!
    I don't really know if it's the right way to get this
    value.
    Could somebody give me some help.

    Regards

    Otto




  • Senator Jay Billington Bulworth

    #2
    Re: .htaccess & .htpasswd

    Otto <ohaldi@freesur f.ch> wrote in news:VA.0000030 1.002e4a76@free surf.ch:
    [color=blue]
    > Hello to all,
    >
    > I have protected a directory with the help of .htaccess &
    > htpasswd.
    >
    > I also read that I can get the login value in a php
    > variable.
    >
    > Like this:
    > $user = $_SERVER['PHP_AUTH_USER'];
    > echo "User : ";
    > echo $user;
    >
    > I did it, but nothing is displayed after the echo User!
    > I don't really know if it's the right way to get this
    > value.
    > Could somebody give me some help.[/color]

    That is the correct way to determine the .htpasswd user's username. In
    order for it to work, the script must be located somewhere inside of the
    ..htpasswd protected directory, and a valid authenticated user must be
    logged in.

    If this all sounds right, and it still isn't working, what is the setup
    of your web server?

    It looks like some early versions of PHP5 had a problem with $_SERVER
    [PHP_AUTH_USER] :

    http://bugs.php.net/bug.php?id=2913 2

    If you're using PHP5, make sure you have the latest release.

    hth


    --

    Bulworth : PHP/MySQL/Unix | Email : str_rot13('f@fu ng.arg'); Web :
    shaunc.com
    --------------------------
    |--------------------------------------------------
    <http://www.phplabs.com/> | PHP scripts and thousands of webmaster
    resources!

    Comment

    • Otto

      #3
      Re: .htaccess &amp; .htpasswd

      Hello Jay
      [color=blue]
      > If you're using PHP5, make sure you have the latest release.
      >[/color]
      Many thanks four your quick answer. I have to look with
      version my webhoster are using!

      Regards

      Otto

      Comment

      Working...