Hey, I'm working on a web app that has a login dialog that works like this:
- User clicks "login"
- Login form HTML is loaded with AJAX and displayed in DIV on page
- User enters user/pass in fields and clicks submit. It's NOT a
<form>
-- user/pass are submitted via AJAX - If user/pass are okay, page reloads with user logged in.
- If user/pass are bad, page does NOT reload but error message appears in DIV and user gets to try again.
Here's the problem: the browser never offers the usual "Save this password? Yes / Never / Not Now" prompt that it does for other sites.
I tried wrapping the <div>
in <form>
tags with "autocomplete='on'" but that made no difference.
Is it possible to get the browser to offer to store the password without a major rework of my login flow?
thanks Eric
p.s. to add to my question, I'm definitely working with browers that store passwords, and I've never clicked "never for this site" ...this is a technical issue with the browser not detecting that it's a login form, not operator error :-)
I spent a lot of time reading the various answers on this thread, and for me, it was actually something slightly different (related, but different). On Mobile Safari (iOS devices), if the login form is HIDDEN when the page loads, the prompt will not appear (after you show the form then submit it). You can test with the following code, which displays the form 5 seconds after the page load. Remove the JS and the display: none and it works. I am yet to find a solution to this, just posted in case anyone else has the same issue and can not figure out the cause.
JS:
HTML:
This solution worked for me posted by Eric on the codingforums
Code:
See if that causes the prompt to appear.
Eric
Posted on http://www.codingforums.com/showthread.php?t=123007
Using a cookie would probably be the best way to do this.
You could have a checkbox for 'Remember me?' and have the form create a cookie to store the //user's login// info. EDIT: User Session Information
To create a cookie, you'll need to process the login form with PHP.
Not every browser (e.g. IE 6) has options to remember credentials.
One thing you can do is to (once the user successfully logs in) store the user information via cookie and have a "Remember Me on this machine" option. That way, when the user comes again (even if he's logged off), your web application can retrieve the cookie and get the user information (user ID + Session ID) and allow him/her to carry on working.
Hope this can be suggestive. :-)
You may attach the dialog to the form, so all those inputs are in a form. The other thing is make the password text field right after the username text field.
Using a button to login:
If you use a
type="button"
with anonclick
handler to login usingajax
, then the browser won't offer to save the password.Since this form does not have a submit button and has no action field, the browser will not offer to save the password.
Using a submit button to login:
However, if you change the button to
type="submit"
and handle the submit, then the browser will offer to save the password.Using this method, the browser should offer to save the password.
Here's the Javascript used in both methods: