Solved

Access login/password information

Posted on 1997-07-05
4
282 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

860 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