主讲老师:郭盛华
什么是 Cookie?
cookie 常用于识别用户。cookie是服务器留在用户计算机中的小文件。每当相同的计算机通过浏览器请求页面时,它同时会发送cookie。通过 PHP,您能够创建并取回 cookie 的值。
如何创建 cookie?
setcookie() 函数用于设置 cookie。
注释:setcookie() 函数必须位于<html> 标签之前。
在下面的例子中,我们将创建名为 "user" 的 cookie,把为它赋值 “hacker"。我们也规定了此 cookie 在一小时后过期:
<?php
setcookie("user", “hacker", time()+36