PHP中COOKIE即时生效,不需要再次刷新页面

WBOY
Release: 2016-06-13 13:01:12
Original
775 people have browsed it

PHP中COOKIE及时生效,不需要再次刷新页面

PHP的COOKIE第一次只是创建了这个COOKIE,再次刷新页面后才能使用这个值。

?

setcookie($var, $value, $time, $path, $domain, $s); //假设COOKIE名称为$var,值为$value
COOKIE[$var] = $value;
Copy after login
?

?

先用setcookie函数创建COOKIE;然后再对COOKIE进行赋值操作。

这样就不用再次刷新,直接就可以获得cookie的值了。

也就是对cookie进行了两次赋值

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