Link to home
Start Free TrialLog in
Avatar of sepp051497
sepp051497Flag for Germany

asked on

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?

Avatar of byoung
byoung

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!
Avatar of sepp051497

ASKER

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);

                                                               

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!
ASKER CERTIFIED SOLUTION
Avatar of icd
icd

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial