Solved

Access login/password information

Posted on 1997-07-05
4
284 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

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 …
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
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…

691 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