Home > php教程 > php手册 > 基于PHP创建Cookie数组的详解

基于PHP创建Cookie数组的详解

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:28:46
Original
1167 people have browsed it

本篇文章是对在PHP中创建Cookie数组的方法进行了详细的分析介绍,需要的朋友参考下

创建:

复制代码 代码如下:


setcookie("ICNet[Reg]", "This is reg cookie", time() + 3600);
setcookie("ICNet[Active]", "This is login cookie.", time() + 3600);
print_r($_COOKIE);


/*Result:
Array (  [ICNet] => Array ( [Reg] => This is reg cookie [Active] => This is login cookie ) [PHPSESSID] => nsi2q5upuvqrik6notaohjd7p3 )
*/
读取:

复制代码 代码如下:


echo $_COOKIE['ICNet']['Reg'];
echo $_COOKIE['ICNet']['Active'];
//或者
$arr_cookie = $_COOKIE['ICNet'];
echo $arr_cookie['Reg'];
echo $arr_cookie['Active'];


销毁:

复制代码 代码如下:


setcookie('ICNet[Reg]', '', time() - 3600);
setcookie('ICNet[Active]', '', time() - 3600);

,香港虚拟主机,服务器空间,香港虚拟主机
Related labels:
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template