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>
No, you can't. PHP runs on your server, the localStorage is only available in the browser of the client.
The only way is to read the localStorage via JavaScript, and send the result to your server via ajax.
I tried with this code and it worked fine.
$Data = "<script>document.write(localStorage.getItem('key'));</script>";
print_r($Data);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With