[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 173
  • Last Modified:

Need to get the USER that logged in...

I have a program that runs on a Secure server.  The user types in a URL that looks somewhat like this..


I need program.pl to be able to get JOE out of that.  The server itself will take care of actually authenticating the user, I just want to be able to grab the user name.  I thought $ENV{REMOTE_USER} was the way to get that but so far it isn't working..
Is that the correct way to get that information and if not, how do I get it?



1 Solution
Try this code:


print "Content-type: text/html\n\n";

foreach (keys %ENV)
print "Key: $_  ==> Value: $ENV{$_}<br>";

It will show you what vars are available.  Make sure to put it in a protected place that forces a log in and ten you'll see if an env var is being created by you server which will work.  Remember that not all servers create the same CGI Env Vars so this shows what ones DO exists.
try this


use CGI;

print "Content-type: text/html\n\n";


$ENV{SERVER_URL}=~ /https:\/\/(.*):.*@.*/;
print $1,"<br>\n";  ##OUPUT will be joe

#### OR YOU CAN USE THIS#########
$tmp[1]=~ s/\/\///g;
print $tmp[1],"<br>\n";##OUPUT will be joe
PalamedesAuthor Commented:
Thanks Guadalupe.. Thank showed it.. it's AUTH_USER  ... sheesh..



Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now