How to get userid from web server

P

Phillip Wu

I have a javascript program that lives in the secure part of a web
site.

In order to get access to this java program the user needs to log in
providing a userid and password. I understand that the userid/password
is verified by the web server (Apache in my case). I also understand
that any server side program written in php can get the userid from
environment variables.

I want to be able to find out the userid that the user logged in as,
from my javascript program (client side).

I know that it would be a breach of security to get the user's
password. I cannot see any security concerns in getting the userid.

How do I get this information - is there an object I can query?

If I cannot get it I suppose the best thing to do was to get the
server side php to put the information into a cookie that the
javascript can read. Is this the best way?

Thanks for any help.
 
M

Marco Dieckhoff

I have a javascript program that lives in the secure part of a web
site.

In order to get access to this java program the user needs to log in

Please notice: javascript has NOTHING do to with java (programs).
providing a userid and password. I understand that the userid/password
is verified by the web server (Apache in my case). I also understand
that any server side program written in php can get the userid from
environment variables.

I want to be able to find out the userid that the user logged in as,
from my javascript program (client side).

If you can use .php, put in your <script>-Section something like
<?php print '$username = ' . $ENV['REMOTE_USER']; ?>

(May be syntactically wrong, especially $ENV... :)
If I cannot get it I suppose the best thing to do was to get the
server side php to put the information into a cookie that the
javascript can read. Is this the best way?

Why using a cookie when you can insert it to your code directly?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top