A.A. PEACE A.A. PEACE - 16 days ago 6
PHP Question

assign a php variable to a sessionStorage var

I am trying to set a php variable value to a HTML5 sessionStorage. Is this feasible? Check my code below:

<script>sessionStorage.username = </script><php echo $_GET["user"]; ?>


Thank you in advance

Answer

Try this:

<script>
    sessionStorage.username = '<?php echo $_GET["user"]; ?>';
</script>

Code edited