Home >Backend Development >PHP Tutorial >PHP cannot obtain Referer troubleshooting, referer troubleshooting_PHP tutorial
Test results:
5b5191fa7d34a5d68ee66c5cf48bfb80'; echo 'ac7a3d90f32e047cb99438b4e66385afEnter page5db79b134e9f6b82c0b36e0489ee08ed076402276aae5dbec7f672f8f4e5cc81'; echo 'Test source: new window opens076402276aae5dbec7f672f8f4e5cc81'; echo 'cc149cdea526c9240b81ff4652ac441aEnter page5db79b134e9f6b82c0b36e0489ee08ed076402276aae5dbec7f672f8f4e5cc81';
The code of test_cookie.php is:
<?php date_default_timezone_set(<span class="str">'Asia/Shanghai'</span>);<span class="rem">//设置默认时区</span> header(<span class="str">'content-type:text/html; charset=utf8'</span>);<span class="rem">//设置返回头信息</span> echo date(<span class="str">'Y-m-d H:i:s'</span>); echo <span class="str">"<br/>\r\n"</span>; echo <span class="str">'PHP获取Refer是:'</span>; $refer=isset($_SERVER[<span class="str">'HTTP_REFERER'</span>])?$_SERVER[<span class="str">'HTTP_REFERER'</span>]:<span class="str">'No refer found'</span>; echo $refer; echo <span class="str">"<br/>\r\n"</span>; echo <span class="str">'JS获取Refer是:'</span>; echo <span class="str">"<script>document.writeln(document.referrer);</script>"</span>; echo <span class="str">"<br/>\r\n"</span>;
I am extremely curious as to why I was able to get it the first time but not the second time.
The environment is LNMPA, the official one is http://lnmp.org/lnmpa.html
Use charles to capture packets on Mac
The headers of the two requests to test1.php are consistent.
The headers of the two requests to test_cookie.php are consistent.
Then the question arises, what causes two identical requests and PHP cannot get the referrer. Kneel down and ask for answers.
For more exciting topics, follow Xiaowu’s blog http://www.lingdonge.com