Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

My experience is that using .htAccess to password protect a directory, it brings up a modal dialog box. And for some browsers (FF and Chrome) don't show the checkbox for "remember" this password.

Is there a way to that a password protect a directory and have the user fill in the username and password within the web page?

Or, is there a way to force the browser to remember that password?

share|improve this question
add comment

3 Answers 3

up vote 4 down vote accepted

Short answer: No

Long answer: The dialog in your browser is opened when the server sends the 401 Not Authorized response code followed by the WWW-Authenticate: Basic realm="insert realm" header. The specs do not include headers to control the dialog behavior.

To display a webpage you need to get a little bit fancier and consult the programming language of your choice.

There is no simple way to achieve what you want with password based authentication

share|improve this answer
add comment

Use a web-application-framework.. like Drupal. Then put this at the top:

// initialize Drupal
// TODO: adjust path according to placement of script (might need to change to Drupal directory first)
require './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
// check user access rights
// TODO: Adjust to the permission you want to restrict to, e.g. 'access content' or whatever
if (!user_access('administer nodes')) {
  // Insufficient rights, say so
  drupal_access_denied();
  exit(0);
}
// ... call legacy script

FYI: IT changes with each version. Then only allow profiles, or users based on their profile name or userid in that system, or as above, the individual permission. http://stackoverflow.com/questions/2496348/checking-drupal-authentication-from-external-php/2499464#2499464

Then use the authentication modules, interactions, protections etc, already built into that. Takes care of all the heavy lifting and updates to the API.

There are loads: Symfony, Magento, Zend... GIYF..

share|improve this answer
add comment

Take a look at the "Auto Auth" Firefox plugin: https://addons.mozilla.org/en-US/firefox/addon/autoauth/

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.