基于PHP创建Cookie数组的详解
(编辑:jimmy 日期: 2024/11/19 浏览:3 次 )
创建:
复制代码 代码如下:
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);
复制代码 代码如下:
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);
下一篇:PHP调用MsSQL Server 2012存储过程获取多结果集(包含output参数)的详解