Access login/password information

I have a HTML-page which is protected by a login/password, just as the login function of experts-exchange.

Does the HTTP server, after verifying the login, send it back to the browser? If so, is there any way to access the user-entered login/password information in JavaScript?

sepp051497Asked:
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.

byoungCommented:
if the user enters the username and password into your (I take it) alert popup window, then you should be able to keep that info with the user as they cruise around your site, by using cookies.  Whether or not the http server sends it bakc to the browser, depends upon how you have configured it(or the default config), but that shouldn't matter if you can have them fill out the dialog box first, 'cause you can get that info(put it into a variable to hold onto.)  hope this helps, and good luck!
0
sepp051497Author Commented:
Thanx for the quick answer, but there seems to be a misunderstanding:

What I want to use is called the "HTTP basic authentification scheme", which makes the Client (browser) open a window and ask for a user/password pair. This information is then sent back to the server, which checks if the user is authorized to access the requested document.

What I want to do is to trigger different actions, depending on the user information. A simple example is to greet the user with his name ("Hello ...").

The Experts-Exchange server seems to use a similar technique: After I have logged myself in, I receive customized pages which includes my current balance and my user name. As I have the "Cookie warnings" turned on in my Browser, there does not seem to be any cookies set.

Thus, there must be a mechanism to create dynamic HTML documents depending on the "basic authentification scheme" login information.

I assume, some CGI script could solve my problem, but is there a way using JavaScript? I thought of something like that:

    document.writeln("Hello " +            document.authentification.login.value);

                                                               

0
byoungCommented:
exactly.  but not document.auth...  if you have:
<form name=UserPassword>
<Input type="text" name="userid" value="anonymous">
<input type="password" name="passid" value="">
<input type="button" name="submit" value="Submit" onClick="UserLogin()"> </form>
then a function in the header:
<script language="JavaScript">
function UserLogin() {
var UserName = document.UserPassword.userid.value;
var Password = document.UserPassword.passid.value;
document.write("{the html you want} Welcome " + UserName + " it's so good to blah blah..");
This produces personalized homepages, and there are many more complicated ways to do it, like you said, with cgi.  Good luck, I hope I was more specific this time!
0
icdCommented:
The browser holds the userid and the password and sends it with every request to the appropriate host and directory.

At the server end it is possible to find out which user is accessing the page by referring to the REMOTE_USER environment variable. This will give the name that the user logged in by. You can (if you wish) then hold a database file on each user referenced by this login. For example you could have a file holding the email address of each user indexed by login name (as does experts-exchange).

0

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

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.