0

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?

0

1 Answer 1

0

Something like this perhaps? You have to echo it to the JavaScript.

<script>
var myVariable = "<?= Yii::app()->user->getState('myVariable', '') ?>";
alert(myVariable);
</script>
Sign up to request clarification or add additional context in comments.

1 Comment

It's the only way for now. I thought may be there is a better solution, but it seems there isn't.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.