opened
papalapa
username_0
### What steps will reproduce the problem?
In controller I have sent cookies like this:
`Yii::$app->response->cookies->add(new yii\web\Cookie(['name' => 'user.name', 'value' => 'Jack Black']));`
and
`Yii::$app->response->cookies->add(new yii\web\Cookie(['name' => 'user-login', 'value' => 'jack']));`

Then to get cookies in view I use code like this:
`Yii::$app->request->cookies->getValue('user.name');`
and
`Yii::$app->request->cookies->getValue('user-login');`

### What is the expected result?
I waiting for `'Jack Black'` and `'jack'`.

### What do you get instead?
I receive a `NULL` value and `'jack'`.

**Why dot symbol is not allowed in cookie?**

### Additional info

| Q                | A
| ---------------- | ---
| Yii version      | 2.0.12
| PHP version      | 5.4
| Operating system | Ubuntu
What is wrong with name of Cookie on getting?
issue
created
samdark
username_1
What do you have in $_COOKIES?
comment
created
dmirogin
username_2
Cause this
`Yii::$app->response->cookies->add(new yii\web\Cookie(['name' => 'user.name', 'value' => 'Jack Black']));`
sets cookie to response. Nothing more.
comment
created
dmirogin
username_2
And you read cookies from request.
Request cookies and response cookies are different cookie bags.
comment
created
samdark
username_1
@username_2 I think he actually means reading cookie in a view in the next request, not the same one. Am I right, @username_0?
comment
created
papalapa
username_0
@username_2, @username_1 is right about setting and getting cookies.
The browser cookies after this manipulations has both variables: user.name and user-login, but on getting  values I have this:
var_dump(Yii::$app->request->cookies->getValue('user-login')); // jack
var_dump(Yii::$app->request->cookies->getValue('user.name')); // NULL

I think problem is in «.» symbol in cookie variable name.
comment
created
samdark
username_1
Yes https://harrybailey.com/2009/04/dots-arent-allowed-in-php-cookie-names/
comment
created
samdark
username_1
Not sure we should handle it.
comment
created
papalapa
username_0
Oh, it is deeper than seems. I have never thinking about global variable names. Thank you @username_1.
comment
created
samdark
username_1
Either we should convert dots to underscores behind the scenes or throw an exception for cookies with dots in their names.
comment
created
papalapa
username_0
I think throwing an exception will be a better way to handle it.
comment
created
samdark
username_1
Yes. Agree.
comment
created
klimov-paul
username_3
Disagreed. There are many symbols, which are not allowed in the Cookie name: spaces `=`, `;` and so on. Should we check them too?

Besides PHP does not put any restriction on setting cookie with dot in the name. The only problem is that appears in `$_COOKIE` with dots been replaced by underscore.
Also this behavior may be fixed in the future PHP versions as 'register_globals' directive has been removed long ago.

I do not think any actions should be performed.
comment
created
samdark
username_1
Makes sense.
comment
closed
samdark
username_1
issue