A custom HTTP header was added at the time of the client request, as follows:
Custom HTTP request Headers
Var_dump (getallheaders);
It started with the getallheaders parameter, but found that it was not available on Nginx deployed servers, and it was very strange to see the PHP manual found that getallheaders this function only supports Apache servers. Then find a compatible method:
if (!function_exists (' getallheaders ')) { function getallheaders () { $headers = array (); foreach ($_server as $name = = $value) { if (substr ($name, 0, 5) = = ' Http_ ') { $headers [Str_replace (' ', '-', UC Words (Strtolower (Str_replace (' _ ', ' ', substr ($name, 5)))])] = $value; } } return $headers; }} Var_dump (Getallheaders ());
In fact, this method is to find the $_server variable in the beginning of the Http_ property, the property to do a string substitution. The http_user_id in the $_server variable is actually the custom User-id above:
$_server Variables in PHP
In addition to the custom HTTP header, you need to pay attention to the naming specification of the header, cannot be named under the underscore , otherwise under the Nginx server can not read, when looking for the naming specification, there is a reference to the custom attribute X-Start the problem. Later, I looked up some information and found that the subsequent HTTP protocol was not recommended. Reference Address:
Http://stackoverflow.com/questions/3561381/custom-http-headers-naming-conventions