This question already has an answer here:
- In Yii, pass PHP variables to JavaScript 6 answers
I am using Yii::app()->user->setState
to set some user's session variables.
Is there a way to get the values of them from within JavaScript?
</div>
This question already has an answer here:
I am using Yii::app()->user->setState
to set some user's session variables.
Is there a way to get the values of them from within JavaScript?
</div>
Something like this perhaps? You have to echo it to the JavaScript.
<script>
var myVariable = "<?= Yii::app()->user->getState('myVariable', '') ?>";
alert(myVariable);
</script>