Home >Backend Development >PHP Tutorial > php COOKIE有关问题

php COOKIE有关问题

WBOY
WBOYOriginal
2016-06-13 13:00:07980browse

php COOKIE问题
if (!isset($_COOKIE['referer'])) {
setcookie('referer',$_SERVER['HTTP_REFERER']);
}
从外部链接过来后在站内点击多次,$_COOKIE['referer']的值为变,谁知道原因呢,求解???
------解决方案--------------------
你一旦set了一次,isset就为true,大括号就进不去,当然不变
------解决方案--------------------
改成这样:

<br />
if ($_COOKIE['referer']!=$_SERVER['HTTP_REFERER']) {<br />
setcookie('referer',$_SERVER['HTTP_REFERER']);<br />
}<br />

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