如何在PHP Session中存储JavaScript函数参数?

i have passed argument in JS method and that methods argument needs to save in PHP Session but failed to do so ....... CODE:

 function checkBoxStatusUser1(condition)
       {

           console.log("condition checkBoxStatusUser1 :"+condition);
           setStatusDataUser(condition);
            <?php
        Yii::app()->session['var'] = condition;
       print_r(Yii::app()->session['var']); // Prints "value"
?>

       }

BUT THIS LOC: Yii::app()->session['var'] = condition; is not assigning condition's value either true or false to the session

Use Ajax for this. If you want to send a javascript variable from client side to server side, you should make an ajax call and send the variable in the 'data' property of the object parameter of the ajax call.

function checkBoxStatusUser1(condition) {
    console.log("condition checkBoxStatusUser1 :" + condition);
    setStatusDataUser(condition);
    $.ajax({
        url: '/requestHandler',
        data: {
            'condition': condition, //here you pass the data
        }
        type: 'post',
    });
}

And on server, make a script to handle request at '/requestHandler' and then do this-

 Yii::app()->session['var'] = $_POST['condition'];

You can get a decent understanding of it here -

http://www.w3schools.com/Ajax/