|
You now have Apache authenticating your users, but this still doesn't provide session management. Fortunately, the hard part is done. Setting up a Perl/CGI script to use session management is pretty simple.
Apache, and, as far as I know, most other web servers, hold a considerable amount of information in "Environment Variables". One of the environment variables is called "REMOTE_USER". Perl can retrieve these environment variables with the use of the $ENV{} variable. So, to extract the contents of an environment variable in a Perl/CGI program, you can use the following code:
my $VARIABLE=$ENV{'VARIABLE_NAME'};
...as in the following example:
#!/usr/bin/perl
use CGI;
my $USER=$ENV{'REMOTE_USER'};
$query=new CGI;
print $query->header;
print "\n";
print " \n";
print " Hello, $USER\n";
print " \n";
print "\n";
Each page that requires session management will need to extract the user's name as shown above. This can then be used in SQL select statements, welcome messages, or whatever.
Here are some other environment variables that can be extracted from the server. |