yii2 Reading a cookie


Example

In order to read a cookie use the following code:

$value = \Yii::$app->getRequest()->getCookies()->getValue('my_cookie');

Note: this code allows read cookies that has been set using cookie component (because it signs all cookies by default). Therefore if you add/update cookie using JS code, you can't read it using this method (by default).