作者:手机用户2702938540 | 来源:互联网 | 2013-06-19 08:50
设置COOKIE:
?
1
2
3
4
5
6 //首先新建COOKIE
$COOKIE=newCHttpCOOKIE('qblog','test COOKIE');
//定义COOKIE的有效期
$COOKIE->expire = time()+60*60*24*30; //有限期30天
//把COOKIE写入COOKIEs使其生效
Yii::app()->request->COOKIEs['qblog']=$COOKIE;
读取COOKIE:
?
1
2 $COOKIE= Yii::app()->request->getCOOKIEs();
echo$COOKIE['qblog']->value;
销毁COOKIE:
?
1
2 $COOKIE= Yii::app()->request->getCOOKIEs();
unset($COOKIE['qblog']);