Test results:
'Test source: load the page directly
';
echo 'Enter page
';
echo 'Test source: new window opens
';
echo 'Enter page
';
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