PHP学习札记(四)cookie

WBOY
Release: 2016-06-13 11:00:01
Original
738 people have browsed it

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>
Copy after login


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

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!