-
- $cookie = new CHttpCookie('mycookie','this is my cookie');
- $cookie->expire = time()+60*60*24*30; //Limited to 30 days
- Yii::app()->request->cookies['mycookie']=$cookie;
Copy code
2, read cookies:
-
- $cookie = Yii::app()->request->getCookies();
- echo $cookie['mycookie']->value;
Copy code
3, Destroy cookies:
-
- $cookie = Yii::app()->request->getCookies();
- unset($cookie[$name]);
Copy code
The above is in the yii framework The most basic cookie operation method is well encapsulated and very simple to use.
|