Home  >  Article  >  Backend Development  >  cookies显示有关问题

cookies显示有关问题

WBOY
WBOYOriginal
2016-06-13 11:19:28798browse

cookies显示问题

<br /><?php <br />setcookie("user", "Alex Porter", time()+3600);<br />echo $_COOKIE["user"];<br />?><br />

页面要刷新一下才可以获取值,请问有没办法解决?


------解决方案--------------------
问题是没实际意义,真想要弄可以换成$_SESSION
------解决方案--------------------
楼主要理解cookie发送的原理。
浏览器像服务器发送请求的时候,浏览器会讲存在客户端的cookie信息通过http协议送过去。
服务器拿到这个cookie后,才能echo。

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