Yii cookie使用方法

设置cookie:
[coolcode lang=”php”]
$cookie = new CHttpCookie(‘mycookie’,’this is my cookie’);
$cookie->expire = time()+60*60*24*30; //有限期30天
Yii::app()->request->cookies[‘mycookie’]=$cookie;
[/coolcode]

读取cookie:
[coolcode lang=”php”]
$cookie = Yii::app()->request->getCookies();
echo $cookie[‘mycookie’]->value;
[/coolcode]

销毁cookie:
[coolcode lang=”php”]
$cookie = Yii::app()->request->getCookies();
unset($cookie[$name]);
[/coolcode]

留下评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注

94 − = 84