You want to pass a variable from HTML5 to PHP, which requires automatic submission. Try it, although I have never tried it myself.
Create an invisible text input. Ask JavaScript to change the input value to the value returned from sessionStorage.getItem ("key") and use the string onload = 'this.form.submit () in the tag.
<form name = 'phpvar' onload='this.form.submit()'><br> <input type = "text" value = sessionStorage.getItem("key")>
I did not do this job for you, but I hope it gives you a good idea.
source share