php – Query array in AJAX


I am trying to obtain by means of ajax and the call to a method in php an array of all the cookies that I have declared, to later obtain the value in a certain view and apply jquery and adjustment of the design. Cookies are visual adjustments that the user defines to personalize their application.

The AJAX call is made in the following way.

    $js = <<registerJs($js);
}

and the method of obtaining cookies is as follows:

 public function actionObtenercookie()
    {
        $cookies = Yii::$app->request->cookies;
        return $cookies;
    }

The idea is to be able to obtain the data of each cookie in ajax, with something similar to data ('BackgroundColor'), and not have to establish a method for each data cookie defined by the user.

Thank you.