学无止境,加油屌丝

cookie笔记 没用到,做个笔记

 

//test1.php
<?php
	setcookie("user[name]","admin",time()+600);
	setcookie("user[pw]","123456",time()+600);
	setcookie("user[city]","china",time()+600);
	echo '创建Cookie信息成功,<a href="test2.php">点击查看Cookie信息</a>';
?>
 
//test2.php
<?php
	echo "Cookie信息:<br/>";
	if(isset($_COOKIE['user'])){
		foreach($_COOKIE['user'] as $key=>$value){
			echo $key."=>".$value."<br/>";
		}
		echo '<a href="test3.php">删除Cookie信息</a>';
	}
	else{
		var_dump($_COOKIE);
	}
?>
 
//test3.php
<?php
	setcookie('user[name]',"");
	setcookie('user[pw]',"123456",time()-1);
	setcookie('user[city]',"china",time()-1);
	echo '已清空Cooike信息,<a href="test2.php">返回查看Cookie信息</a>';
?>
————————————————
版权声明:本文为CSDN博主「_xw2018」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/sm20170867238/article/details/90762010

  

posted @ 2021-03-31 15:49  nofeel666  阅读(23)  评论(0编辑  收藏  举报