Cookie management in Yii

Comparing #11 with #12

Revision #12 was created by Suralc Suralc on Aug 2, 2012, 7:47:51 AM.

Updated in preparation for 1.1.12

Content

[...]
### 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")
[...]