Home >Backend Development >PHP Tutorial >Detailed explanation of creating Cookie array based on PHP_PHP tutorial

Detailed explanation of creating Cookie array based on PHP_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-21 15:01:10831browse

Create:

Copy code The code is as follows:

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 )
*/
Read:
Copy code The code is as follows:

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

Destroy:
Copy code The code is as follows:

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/328017.htmlTechArticleCreation: Copy the code as follows: setcookie("ICNet[Reg]", "This is reg cookie", time () + 3600); setcookie("ICNet[Active]", "This is login cookie.", time() + 3600); print_r($_COOKI...
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