设置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]);