Home >Backend Development >PHP Tutorial >PHP cannot obtain Referer troubleshooting, referer troubleshooting_PHP tutorial

PHP cannot obtain Referer troubleshooting, referer troubleshooting_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:44:381628browse

PHP cannot obtain Referer troubleshooting, referer troubleshooting

Test results:

PHP cannot obtain Referer troubleshooting, referer troubleshooting_PHP tutorial5b5191fa7d34a5d68ee66c5cf48bfb80'; 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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1048744.htmlTechArticlePHP cannot obtain Referer troubleshooting, referer troubleshooting test results: ?phpecho 'Test source: directly load the pagebr/ ' ;echo 'a href="test_cookie.php"Enter page/abr/' ;echo 'Test source...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn