I want to set session inside the javascript. But all the time this function return false value. Please tell me the error of this code.
<script>
function myFunction(){
var r=confirm("Would you like to add another item ?");
if (r==true) {
    alert('ok');
    var varname = '<?php echo $_SESSION["redirect"]=1; ?>';     
 } 
 if(r==false)   {
     alert('bad');
    var varname = '<?php echo $_SESSION["redirect"]=2; ?>';
 }  
}
</script>
 
     
    