设置cookie:
[coolcode lang=”php”]
$cookie = new CHttpCookie(‘mycookie’,’this is my cookie’);
$cookie->expire = time()+60*60*24*30; //有限期30天
Yii::app()->request->cookies[‘mycookie’]=$cookie;
[/coolcode]
读取cookie:
[coolcode lang=”php”]
$cookie = Yii::app()->request->getCookies();
echo $cookie[‘mycookie’]->value;
[/coolcode]
销毁cookie:
[coolcode lang=”php”]
$cookie = Yii::app()->request->getCookies();
unset($cookie[$name]);
[/coolcode]