Send data between controllers


(alexsultana) #1

Hello, I need to send an array from one controller to another. The array have many elements, i can’t send it as a parameter in url. Any Ideas ? What I need is acces at this array data from another controller, other than the controller who make the array.

Thank you!


(Fabrizio Caldarelli) #2

Export code in a component (right way) and consume it inside the current controller or call the other controller using http client from current controller (bad way).


(Alexander Makarov) #3

Use POST request.


(Eloy Gonzalez) #4

Hi @alexsultana;

Send data between controllers using,

\yii\helpers\Url::toRoute();
or 
\yii\helpers\Url::to();
function inside controller