I came across a question which raised me some sort of curiosity. Is it possible to read custom headers sent in a different request?
Using header_list() it's possible to read the headers sent, like the Content-type one. So, in the same request, this code:
<?php
header( 'My Header: My Value' );
print '<pre>';
print_r( headers_list() );
Would produce:
Array
(
[0] => X-Powered-By: PHP/5.4.24
[1] => My Header: My Value
[2] => Content-type: text/html
)
But what if I would like to get the My Header header in a different request, to a different URL maybe, after sending a Location header like this?
<?php
header( 'My Header: My Value' );
header( 'Location: test2.php' );
The print_r(), if used in test2.php lists the Content-type and the X-Powered-By, but it doesn't read the My Header header.