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

php COOKIE有关问题

WBOY
Release: 2016-06-13 13:00:07
Original
959 people have browsed it

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 />
Copy after login

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template