2011-08-23 16:10:37 1 评论 Yii 1.0 Boy.Lee

Yii 1.0 操作 Cookies

Code Here. ^&^

{Create}

$cookie = new CHttpCookie('mycookie','cookies from YiiLib.com');
$cookie->expire = time()+60*60*24*30;  //30 天
Yii::app()->request->cookies['yiilib']=$cookie;

 

{Read} 

$cookie = Yii::app()->request->getCookies();
echo $cookie['yiilib']->value; //cookies from YiiLib.com

 

{Destory}

$cookie = Yii::app()->request->getCookies();
unset($cookie['yiilib']);

 

非常容易实现有没有? ^&^

wiki link http://www.yiiframework.com/wiki/152/cookie-management-in-yii/