<?php //1.设置cookies setcookie('userName','Kevin Wong',time()+3600); setcookie('email','KevinW@php.cn'); //2.查看:$_cookie echo '用户名:', $_COOKIE['userName'],'<br>'; echo '邮箱:', $_COOKIE['email'],'<br>'; //3.更新 //$_COOKIE['userName'] = 'aaa'; setcookie('userName','Kevin Wong'); //4.删除 //方法:1 //setcookie('userName'); //方法:2 //setcookie('userName'); //方法:3 setcookie('userName','',time()-3600);
点击 "运行实例" 按钮查看在线实例