读取先前请求的标题

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.

No, it's not possible to get the header list of a different request. The most obvious question would be: which different request?! There can be thousands of simultaneous "other" requests going on, so "another" request is a bit vague.

If you need to retain that information for later, store it somewhere, for example in the session.