萬盛學電腦網

 萬盛學電腦網 >> 網絡編程 >> php編程 >> 基於PHP創建Cookie數組的詳解

基於PHP創建Cookie數組的詳解

本篇文章是對在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);

copyright © 萬盛學電腦網 all rights reserved