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 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?



Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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..


It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.