PHP学习笔记(四)cookie
1.setcookie() 函数用于设置 cookie
setcookie(name, value, expire, path, domain);
cookie常用于识别用户。setcookie() 函数必须位于 100db36a723c770d327fc0aef2ce13b1 标签之前。
2.$_COOKIE取回cookie的值
3.isset()函数来确认是否已设置了 cookie
<html><body><?phpif (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>
<?php // set the expiration date to one hour agosetcookie("user", "", time()-3600);?>