Changes
                            
    Title
    unchanged
    Cookie management in Yii
    Category
    unchanged
    How-tos
    Yii version
    unchanged
    
    Tags
    unchanged
    cookies, cookie, chttpcookie, ccookiecollection, safe reading
    Content
    changed
    [...]
See also "Safe reading" in the next chapter.
### Writing a cookie
There are multiple ways to write a cookie:
 
 
Since Yii 1.1.11 you don't have to specify the name of the cookie twice.
 
 
```php 
Yii::app()->request->cookies->add(new CHttpCookie('cookie_name', $value));
 
```
 
**Note**: The `old` variant is still valid.
 
Notice, that you have to specify the name twice, if you want to use this:
```php[...]
```php
$cookieCollection->add(['name'] = new CHttpCookie('name', 'value', $options)
);
```[...]
## Links
[Russian version](http://resurtm.kzcom/working-with-cookies-in-yii)