'Can I get data from localstorage using php
Can I get data from localstorage using php if yes then tell me how in localstorage data set like this
<script>
var i=0;
function inc()
{
i+=1;
localStorage.setItem("qnum", i);
}
</script>
Solution 1:[1]
I tried with this code and it worked fine.
$Data = "<script>document.write(localStorage.getItem('key'));</script>";
print_r($Data);
Solution 2:[2]
localStorage is something that is kept on the client side. There is no data transmitted to the server side.
You can only get the data with JavaScript and you could sent it to the server side with Ajax.
Solution 3:[3]
Another explanation goes like this: Your browser does not understand php, only javascript (along with html & css). Therefore, you need to read and set LocalStorage with Javascript and send it to a server, like Markus says.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | nniks19 |
| Solution 2 | Luca Kiebel |
| Solution 3 | Sventies |
