PHP Security: HTTP AuthenticationTag: security, login, authentication, HTTP authentication, HTTP Category: PHP Securitypost: 27 Feb 2008 read: 684 PHP Security HTTP Authentication Step By Step Tutorial - Part 1:You possible have found a web page that you want to open, sudden peep out a dialog window asking for username and password. common example is early page at cpanel (control panel to manage the web server use web based). It use HTTP Authentication. In protecting web page with HTTP authentication, you have to deliver two header. header WWW-AUTHENTICATE tell to browser that an username and password needed. The other header is the status, which should be HTTP/1.0 401 Unauthorized. Compare this to the usual header, HTTP/1.0 200 OK. Example, create a file named "protectHTTP.php" within www\test\phpsecurity. Enter following code:
Point your browser to http://localhost/test/phpsecurity/protecthttp.php. You will get like this:
PHP creates the PHP_AUTH_USER and PHP_AUTH_PW elements of the _SERVER array automatically if the browser passes a username and password. |
| | Give Your Opinion | Recommend |
|


