cookie和session解决方法

WBOY
Release: 2016-06-13 12:55:56
Original
800 people have browsed it

cookie和session
  setcookie("mm","gg");
  echo $_COOKIE["mm"];
?>

2个问题:

(1)
说如果没设置失效时间,则关闭浏览器就自动删除cookie,可我在chrome下关闭浏览器后,再打开还是可以输出gg?

(2)
说cookie设置后必须刷新一次才能生效。这是因为setcookie后,服务器将cookie发送给浏览器,再刷新一次的目的是浏览器将cookie送回。
那为什么session不需要重新刷新呢?毕竟sessionID保存在客户端不也是cookie得形式吗?难道不需要刷新传回sessionID方便服务器识别?

------解决方案--------------------

session是存在服务器上,不是存在客户端的

探讨
setcookie("mm","gg");
echo $_COOKIE["mm"];
?>

2个问题:

(1)
说如果没设置失效时间,则关闭浏览器就自动删除cookie,可我在chrome下关闭浏览器后,再打开还是可以输出gg?

(2)
说cookie设置后必须刷新一次才能生效。这是因为setcookie后,服务器将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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!