Check If Html5 Sessionstorage Value Exists With Php (like With Cookies)
Solution 1:
If you mean by sessionStorage the HTML5 web storage (as I understand from the tags in your question), then no. It is not possible to access this data from PHP. It can only be accessed with JavaScript and passed through to PHP with AJAX.
Solution 2:
No. PHP is server side language and storage or cache are browser dependent, so it is not possible check storage or cache directly from server.
Solution 3:
This worked.
HTML side:
<bodyonLoad="submitform()"><formname="myform"method="post"action="example.php"><inputtype="text"name = "var"id="var"></form><scripttype="text/javascript">functionsubmitform()
{
document.getElementById("var").value = sessionStorage.getItem('var');
document.myform.submit();
}
</script>
PHP side:
echo$_REQUEST['var'];
Solution 4:
You want to pass a variable from HTML5 into PHP, which requires auto-submit. Try this, though I've never tried it myself.
Create an invisible text input. Have JavaScript change the input value to the value returned from sessionStorage.getItem("key"), and use the onload='this.form.submit()' line in the tag.
<formname = 'phpvar'onload='this.form.submit()'><br><inputtype = "text"value = sessionStorage.getItem("key")>
I didn't actually do the work for you, but I hope this gives you a good idea.
Post a Comment for "Check If Html5 Sessionstorage Value Exists With Php (like With Cookies)"