phphtmlsessionstorage

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


Solution

  • Try this:

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

    Code edited