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]);
以上就是yii框架中最基础的cookie操作方法,封装的很好,使用起来很简单。