How to setup a password to enter my web page?

Webber16 used Ask the Experts™
How to add a password requirement to enter my webpage using HTML or PHP?  Other application to use?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2004
There's really two options:

1) Secure the site at the web server.  With Apache, that is done with mod_auth* series of modules.  You can see here and here for some basic examples of how to set this up.  You can see some similar information for IIS here.

2) Secure at the application level.  This generally involves using some kind of application framework, though it is certainly possible to roll your own.  If you want to pursue this option, we'll need more information on what kind of application you have.
Distinguished Expert 2017
As Steve pointed out, on the web server side, you would remove the allow anonymous access.

On the application level, you would retain anonymous access but the php code using cookies will manage the access/authorization/rights.
Take a look at this simple example based .htaccess method on Steve 1)  suggestion

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial