The username and password is checked by the server, and if
legitimate, the user is allowed access. In addition to allowing the
user access to the protected file, the server also maintains the
user's name and passes it to any subsequent CGI programs that
are called. The server passes the username in the
$ENV{REMOTE_USER} environment variable.
A CGI script can therefore use server authentication information to
identify users. Here is a snippet of code that illustrates what you
can do with the $ENV{REMOTE_USER} environment
variable:
$remote_user = $ENV{REMOTE_USER};
if ( $remote_user eq "mary" ) {
print "Welcome Mary, how is your company doing these days?\n";
} elsif ( $remote_user eq "bob" ) {
print "Hey Bob, how are you doing? I heard you were sick.\n";
}