ela has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks, I have developed a website using CGI perl. I am using apache authentication for my website. Is there a way to get to know the username and/or password of the users through my perl code who are successfully authenticated by apache? Thanks, Ela.

Replies are listed 'Best First'.
Re: Apache Username
by moritz (Cardinal) on Nov 21, 2008 at 12:39 UTC
    The user name should be available through $ENV{HTTP_USER} (if that's not the right one, it's another entry of %ENV).
      $ENV{REMOTE_USER}
Re: Apache Username
by hangon (Deacon) on Nov 22, 2008 at 05:36 UTC

    Besides getting it from %ENV, you can also access the username via the CGI module. In either case it's only defined if the user is logged in. You cannot retreive the password unless you write your own password management system. Passwords are not available in the cgi environment, and are by default stored on the web server via one way encryption.

    $username = $ENV{REMOTE_USER}; $username = $q->remote_user; $username = remote_user();