How to get custom header from HTTP response in Laravel 5?
Have you tried simple php?
<?php// Replace XXXXXX_XXXX with the name of the header you need in UPPERCASE$headerStringValue = $_SERVER['HTTP_XXXXXX_XXXX'];
Full answer:https://stackoverflow.com/a/541463/3548658
The docs says:https://laravel.com/api/5.3/Illuminate/Http/Request.html#method_header
use Request;Request::header('accessing_from');
getting a custom header in Laravel 5.8.
this should apply to earlier versions as well.
If using a header like X-Requested-With: XMLHttpRequest
you may notice that it converts this to HTTP_X_REQUESTED_WITH
.
This, in turn, is converted to lower case version for the header()
method.
request()->header('x_requested_with');
I would suggest using Accessing-From: admin
which will add the apache header HTTP_ACCESSING_FROM
. And you will be able to access it via the header function like this...
request()->header('accessing_from');