how to have password fill in automatically on login page

Hi,

I am creating a login page for an app (written in php but I don't think that matters in this case). How do I make it so that once they've logged in one time, the next time the fill in their login name, the password is already filled in. Do I need to set a cookie?

Thanks.
alpineerAsked:
Who is Participating?
 
RouchieConnect With a Mentor Commented:
This is browser functionality and not server/client-side code.  Most browsers now will remember all usernames and/or passwords and enter them automatically.  If numerous passwords are stored for one username box, you may even see a list of these user names when you come to edit the text in that box.

Therefore you need to make sure the browser will remember these details.  In most office environments this is disabled for security reasons, so you might need to enable them again.

 In IE,  goto Tools > Internet Options > Content > AutoComplete > Enable Usernames and Passwords on forms
 In Mozilla, goto Tools > Options > Privacy > Saved Passwords > Enable Remember Passwords

If you do not want to use built-in browser functionality, you'll have a tricky job of outputting all passwords into the HTML code then using javascript to fill-in the password field based on the user name.  This would be quite awkward but I'm sure there's plenty of users on EE who could do this for you.  The result may not work across all browsers as intended though because the browser-functionality detailed above would interfere with your javascript.
0
 
aprestoCommented:
Well normally this is an operating system setting, you know when it pops up and asks if you would like to save the username and password.

But if you want to set up a cookie you could use this to not only save their password but actually eliminate the login process.  Have the login page scan for a cookie, if one is found, read the content, query thi against the database and log them in, check www.w3schools.com/asp/

and check the cookies section for more info
0
 
RouchieCommented:
apresto is correct; you can eliminate the login process entirely by saving a cookie after a successful login attempt.  By using php (or whatever) to fill in the password field means displaying the password in the source code, which is a massive security risk, as anyone sharing the machine could view this.
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

 
alpineerAuthor Commented:
I can't login them in automatically. Even though they will only be using this from their office, they change computers often (ie move from desk to desk) so the same person isn't always at the same computer.

I just wanted it to fill in the password edit box automatically when they fill in the username edit box. Basically so I can convince them to have more secure passwords. They won't be easy to remember so I want the field to be filled out automatically, if possible.

I am using IE 6 and it doesn't ask me if I want to save the password. It is defined as a password input field. The username is remembered. I just tried on another computer that I've never used to login and it didn't ask me either (again IE 6).

Any ideas? Could it be because I have other fields on the form than just username and password?

0
 
Saber37886661Commented:
What is your server OS?
We used to do something simular with a Novell script which would grab thier Novell username and compare it to the 1 in the SQL database for the intranet site, which would then ship the intranets username and password back tho the user using ASP, and then javascript to automatically go to the next url. eg http://blah.com?uname=<%username%>&pass=<%pass%>

doing it this way gets around the office chair swapping bit....but u then have to enforce passwords more vigorously
0
 
alpineerAuthor Commented:
Server is unix. App is php. But I think I need something client side, like a cookie.
0
 
alpineerAuthor Commented:
So if I do save their login info in a cookie, how do I then use that info to fill in the password field when they type the username. Sounds like I need to javascript to do this.
0
 
Saber37886661Commented:
check out this page, kinda easy explanation with the depth u need.
http://tech.irt.org/articles/js025/index.htm
0
 
jericotolentinoCommented:
>> I just wanted it to fill in the password edit box automatically when they fill in the username edit box. Basically so I can convince them to have more secure passwords. They won't be easy to remember so I want the field to be filled out automatically, if possible.

All right, good point. You can also use $_SESSION if you're going with PHP.

Just do something like this on your login verification script...

session_start();
$_SESSION['username'] = $_POST['username'];
$_SESSION['password'] = $_POST['password'];

Then on the page where the user edits the password, just place these lines.

session_start();
if((!$_SESSION['username']) || (!$_SESSION['password'])) {
header("location: login.php");
exit;
}

;-)
0
 
ldbkuttyCommented:
You can use "Remember Me" feature so that the username/password is stored in the client computer as cookie and next time they don't need to enter their login info again. Here's a how-to-do description: http:Q_21086125.html

>> I just wanted it to fill in the password edit box automatically when they fill in the username edit box. Basically so I can convince them to have more secure passwords. They won't be easy to remember so I want the field to be filled out automatically, if possible

If you consider having more secured password, storing the info in cookie is NOT a good idea too!

Have a seperate DB table that stores the login information (user name or userid) with the time of expiry and a unique random string. Store the unique random string in the DB as well as in the cookie, so the original login information is not revealed to the public!
0
 
alpineerAuthor Commented:
For some reason, I just can't seem to get through on this one. I do not want to log the user in automatically, as in the remember me example. I do not want the user to go to the home page of the app and automatically be logged in as joeuser. I can't have this because in the office, several people share the same computer. So it might be maryuser sitting at the keyboard instead of joeuser.

What I was hoping to do would be that when joeuser types in his usernameand hits the tab key, his password would already be in the password edit box. (this, of course, only after he has logged in at least one before). I want the user to type in their username but not have to type in their password.

It happend right here on EE. I just logged out (I was automatically logged in). I went to the home page, typed in my username and the first time I had to type in my password. I logged out again. Went to the home page. Typed in my username, hit the tab key and voilà, there was my password already typed for me. So it is happening client side as soon as the username edit box loses focus.

This is what I wanted to do. I hope it is clearer now. I've upped the points.
0
 
alpineerAuthor Commented:
Thanks, Rouchie. Your response makes perfect sense. And I definitely want to use built-in browser functionality. It just doesn't work for some reason!

I have IE 6 on Win XP. The browser never asked me to save the password, as happens with other sites.

I checked my browser settings and all autocomplete checkboxes were checked. Even prompt me to save...

And in the username edit box, all previous usernames have been saved. When I type in the first letter, I get the dropdown with the list. If I choose one of them, I should get the related password, but I don't.

Here is my form:

    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table width="600" border="0" align="center" cellpadding="4" cellspacing="0">
      <tr>
        <td colspan="2" align="right" class="mandatory">required fields</td>
        </tr>
      <tr>
        <td align="right" class="mandatory">User name:</td>
        <td><input name="username" type="text" id="username" size="16" maxlength="16"></td>
        </tr>
      <tr>
        <td align="right" class="mandatory">Password:</td>
        <td><input name="password" type="password" id="password" size="16" maxlength="16"></td>
      </tr>
      <tr>
        <td align="right" class="mandatory">Op sig:</td>
        <td><input name="initials" type="text" id="initials" size="4" maxlength="2"></td>
      </tr>
      <tr>
        <td align="center">&nbsp;</td>
        <td><input name="maint" type="checkbox" id="maint" value="1">Do maintenance? </td>
        </tr>
      <tr>
        <td align="center">&nbsp;</td>
        <td><input type="submit" name="Submit" value="Login" onClick="return(checkForm());"></td>
        </tr>
    </table>
      </form>


Any idea why this wouldn't work with autocomplete? As I said, it does store the username field, just not the password. And this does work for me on the login page for EE. I also tried on another computer I have here. IE 6 on Win2k. It doesn't work there either.

0
 
RouchieCommented:
I've had a similar problem.  Open the browser on a blank page, then go into the AutoComplete box and uncheck all the 4 options, then press *both* CLEAR buttons to wipe all usernames and passwords.  Press OK and close the browser completely.

Open a fresh browser window and go back into AutoComplete again.  Now re-check all the boxes so they are enabled, press OK and close the browser.

Now when the browser is opened (again!) and the page with the username/password fields is used, it should once again start asking you to save the information you enter once you try to login.

Note that if at any one time you check the box saying "Do not prompt to remember passwords..." it will mess up the above settings and probably not prompt again despite being re-enabled!  Then you'll have to repeat the above all over again!

Not sure why this happens but that's the way I managed to fix it for me...!
0
 
alpineerAuthor Commented:
I tried your suggestion. Actually, even before I read it I decided to try to clear all passwords. But the browser hangs. I read somewhere that I should have tried clearing all form data before passwords. Then I read elsewhere to delete the SPW key on the Intelliforms entry in the registry to resolve the browser hanging problem. Did that to but it still hangs whether I click clear form data or passwords. And it doesn't seem to be deleting anything. I still have all my usernames in the edit box.

Anyway, I went through your routine, except for clearing the data and it made no difference.

Any other ideas?
0
 
RouchieCommented:
If the browser hangs then sadly this seems like a browser issue and not a code-related issue - sorry!  

It should only take a couple of seconds to clear the user and password data (unless you have hundreds of people sharing machines).  Nothing should hang and the data should definitely be deleted.

I think the problem therefore may be out of scope for this question area...
The only other thing I would suggest is making sure you are logged in as the administrator account before clearing the data.

If you don't have the time to reinstall browser / service packs etc then you could always download an alternative browser such as firefox for example - just for testing purposes for this problem...???
0
 
Asta CuConnect With a Mentor Commented:
Have you again cleared the cache (IE temp files including offline content and history files); cleared any related cookies to recreate and unchecked all autocomplete items, closed IE and tried again to recheck the autocomplete items you want?  Any changes made to IE need to have IE closed/reopened to ensure changes are made...  Multiple users involved?

This from IE Help...
To delete Autocomplete entries from the Address bar list

The AutoComplete feature saves previous entries you've made for Web addresses, forms, and passwords. To delete entries from the Address bar, you must clear your History folder. You cannot clear individual entries from the list of saved entries.

On the Tools menu in Internet Explorer, click Internet Options.
Click the General tab.
Under History, click Clear History.
 Notes

When typing information in Web forms, and typing passwords, you can remove an item from the list of suggestions by clicking the item and then pressing the DELETE key.
For Help on an item, click  at the top of the dialog box, and then click the item.
0
 
Asta CuCommented:
0
 
alpineerAuthor Commented:
You guys will never believe this. I kept asking myself, without any special code on the page, how does the browser know to pair up the username/password fields. They don't have to be named in any special way. In fact, I asked above if the fact that I have some extra fields on the form makes any difference. AND IT DOES!

I have a username, a password (of type password), another edit box and a check box. I took off the extra edit box and all works like a charm. I guess for this to work you can only have one input of type text and another of type password. Any other edit boxes throws things off. Checkboxes don't seem to cause any problems. In fact, there is often a remember me checkbox on login forms.

I tried this on the computer that hangs and on another. Both work fine. I put the extra edit box back and it stopped working.  

Thanks to all who contributed. Even though I finally figured this out myself, I will divvy up the points to those of you who put me on the path to the solution.

0
 
RouchieCommented:
No probs alpineer, glad you got it sorted...!  :-)
0
 
Asta CuCommented:
Yay!  Good news, thank you.  ":0)  This can also help others now that it's moved to our PAQ.
Best wishes to you,
":0) Asta
0
All Courses

From novice to tech pro — start learning today.