Solved

Access login/password information

Posted on 1997-07-05
4
269 Views
Last Modified: 2011-10-03
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?

0
Comment
Question by:sepp051497
  • 2
4 Comments
 
LVL 1

Expert Comment

by:byoung
ID: 1268241
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
 

Author Comment

by:sepp051497
ID: 1268242
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
 
LVL 1

Expert Comment

by:byoung
ID: 1268243
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
 
LVL 5

Accepted Solution

by:
icd earned 100 total points
ID: 1268244
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

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now