1.setcookie() 函数用于设置 cookie
setcookie(name, value, expire, path, domain);
cookie常用于识别用户。setcookie() 函数必须位于 <html> 标签之前。
2.$_COOKIE取回cookie的值
3.isset()函数来确认是否已设置了 cookie
<html>
<body>
<?php
if (isset($_COOKIE["user"]))
{
// Print a cookie
echo $_COOKIE["user"];
// A way to view all cookies
print_r($_COOKIE);
}
else
echo "Welcome guest!<br />";
?>
</body>
</html>
4.cookie删除
<?php
// set the expiration date to one hour ago
setcookie("user", "", time()-3600);
?>