Home >Backend Development >PHP Tutorial >PHP学习札记(四)cookie

PHP学习札记(四)cookie

WBOY
WBOYOriginal
2016-06-13 11:00:01774browse

PHP学习笔记(四)cookie
1.setcookie() 函数用于设置 cookie
setcookie(name, value, expire, path, domain);
cookie常用于识别用户。setcookie() 函数必须位于 标签之前。

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>


4.cookie删除
<?php // set the expiration date to one hour agosetcookie("user", "", time()-3600);?>

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