Tag Archives: HTTP

HTTP Authentication

It is possible to use the header() function to send an “Authentication Required” message to the client browser causing it to pop up a Username/Password input window. Once the user has filled in a username and a password, the URL containing the PHP script will be called again with the predefined variables PHP_AUTH_USER, PHP_AUTH_PW, and AUTH_TYPE set to the user name, password and authentication type respectively. These predefined variables are found in the $_SERVER array. Both “Basic” and “Digest” (since PHP 5.1.0) authentication methods are supported Continue reading HTTP Authentication

headers_list()

It returns a list of response headers sent

Example

<?php
 setcookie("time",time());
 header('Content-type: text/plain');
 echo "<pre>";
 print_r(headers_list());
 ?>

Output

<pre>Array
 (
 [0] => X-Powered-By: PHP/5.3.3-1ubuntu9.10
 [1] => Set-Cookie: time=1337938449
 [2] => Content-type: text/plain
 )