Thursday, December 27, 2018

javascript - Get localStorage value into php




I have a variable set in localStorage and I want to get it into php. When php is executed the value is already set in local storage, but how should I get into php?




I tried something like this:



  $myvar = "";


But this for some reasons gives a Uncaught SyntaxError: missing ) after argument list



How should I approach this? Thanks.


Answer




You can not directly get a localStorage value in PHP, when script is executed, because localStorage is contained in user's browser, and PHP is running on server. However, you can send the value from localStorage to a server with GET or POST request.


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...