yii操作cookie实例简介
程序员文章站
2022-06-13 19:49:23
yii对cookie的操作常见的主要有以下几种:
1.设置cookie:
$cookie = new chttpcookie('mycookie','this...
yii对cookie的操作常见的主要有以下几种:
1.设置cookie:
$cookie = new chttpcookie('mycookie','this is my cookie'); $cookie->expire = time()+60*60*24*30; //有限期30天 yii::app()->request->cookies['mycookie']=$cookie;
2.读取cookie:
$cookie = yii::app()->request->getcookies(); echo $cookie['mycookie']->value;
3.销毁cookie:
$cookie = yii::app()->request->getcookies(); unset($cookie[$name]);
上一篇: SNS运营过程的一些小秘密