Revision #12 has been created by Suralc on Aug 2, 2012, 7:47:51 AM with the memo:
Updated in preparation for 1.1.12
« previous (#11) next (#13) »
Changes
Title
unchanged
Cookie management in Yii
Category
unchanged
How-tos
Yii version
unchanged
Tags
unchanged
cookies, cookie, chttpcookie, ccookiecollection, safe reading
Content
changed
[...]
### 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)
);
```
The option parameter is internally passed to the public method [CHttpCookie::configure()](http://www.yiiframework.com/doc/api/1.1/CHttpCookie#configure-detail "CHttpCookie::configure()") which accepts an array with the following keys:
- [domain](http://www.yiiframework.com/doc/api/1.1/CHttpCookie#domain-detail "domain")[...]