yii 操作cookie

原文地址:http://blog.sina.com.cn/s/blog_664c9f650100yqkn.html

设置cookie:

  1. $cookie new CHttpCookie('mycookie','this is my cookie');
  2. $cookie->expire time()+60*60*24*30 //有限期30天
  3. Yii::app()->request->cookies['mycookie']=$cookie;

读取cookie:

  1. $cookie Yii::app()->request->getCookies();
  2. echo $cookie['mycookie']->value;

销毁cookie:

  1. $cookie Yii::app()->request->getCookies();
  2. unset($cookie[$name]);
posted @ 2012-03-14 09:40  夏至冬末  阅读(169)  评论(0编辑  收藏  举报