yii\web\Request::loadCookies PHP Method

loadCookies() protected method

Converts $_COOKIE into an array of Cookie.
protected loadCookies ( ) : array
return array the cookies obtained from request
    protected function loadCookies()
    {
        $cookies = [];
        if ($this->enableCookieValidation) {
            if ($this->cookieValidationKey == '') {
                throw new InvalidConfigException(get_class($this) . '::cookieValidationKey must be configured with a secret key.');
            }
            foreach ($_COOKIE as $name => $value) {
                if (!is_string($value)) {
                    continue;
                }
                $data = Yii::$app->getSecurity()->validateData($value, $this->cookieValidationKey);
                if ($data === false) {
                    continue;
                }
                $data = @unserialize($data);
                if (is_array($data) && isset($data[0], $data[1]) && $data[0] === $name) {
                    $cookies[$name] = new Cookie(['name' => $name, 'value' => $data[1], 'expire' => null]);
                }
            }
        } else {
            foreach ($_COOKIE as $name => $value) {
                $cookies[$name] = new Cookie(['name' => $name, 'value' => $value, 'expire' => null]);
            }
        }
        return $cookies;
    }