I’m using this code to set language in yii
setcookie("lang", $_GET['lang'], time() + 31104000, "/"); // 86400 = 1 day
I’ve put it in \vendor\yiisoft\yii2\web\Controller.php
But I kinnda think it is not the best solution. What would be best solution to set language of my app.
I’m looking for something where I can execute my code before any action of any controller
@darioo, Did you got the solution for this problem you described. I’m also getting same problem. If you have any solution update it here it will helpful all others.
Derive your own controller from "\yii\web\Controller", implement its "beforeAction" and then derive every other controller from that base controller.
Hi darioo here ist very good Tutorial from samdark: