1

I am assigning the javascript value to php but plus sign is not exist in output after printing and cannot escape it.

<script type="text/javascript">
    document.cookie = "mydata =index.php?test=1+test2=1";
</script>

<?php 
   $myPHPdata =  $_COOKIE['mydata'];

   echo $myPHPdata;
?>

Getting this output without plus sign(+) => "index.php?test=1 test2=1" plus is mssign

How can i print plus sign too ?

user6618536
  • 207
  • 2
  • 3
  • 11

1 Answers1

1

Do this. It will work.

var plus = encodeURIComponent('+');
document.cookie = "mydata=index.php?test=1"+ plus +"test2=1";
Rahul Chauhan
  • 1,424
  • 14
  • 13