For Yii2, this is done as follows:
defined('YII_DEBUG') or define('YII_DEBUG', true);
Then you probably want to immediately open a session so that $ _SESSION is always available in the future:
Yii::$app->session->open();
Now you can use either $_SESSION as usual, or use, for example. Yii::$app->session['sessionvarname'] = 'somevalue'; (or any method described in the chapter of the Session and Cookies manual).
In addition, if you want to use some of the Yii assets, you can download them as follows:
$asset = Yii::$app->assetManager->getBundle('yii\web\YiiAsset', true); echo yii\helpers\Html::jsFile(Yii::$app->assetManager->getAssetUrl($asset, 'yii.js')); // -- or -- echo '<script type="text/javascript" src="'. Yii::$app->assetManager->getAssetUrl($asset, 'yii.js') .'"></script>';
source share