-
- $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操作方法,封装的很好,使用起来很简单。
|