title: Sending localStorage data to PHP
body: <p>I've done some research and even have a book that explains Ajax calls to php and sending data to and from browser and server. I found this to be pretty close to what I need since I am using local storage <a href="https://stackoverflow.com/questions/16042565/how-can-i-pass-saved-localstorage-web-data-to-a-php-script">How can I pass saved localStorage web data to a php script?</a>, this link seems pretty coherent but I am not sure what to do on the PHP side <a href="https://stackoverflow.com/questions/406316/how-to-pass-data-from-javascript-to-php-and-vice-versa">How to pass data from Javascript to PHP and vice versa?</a>, </p>
  
  <p>though I have a bigger problem, the amount of data I have in local storage is pretty large, there are several different arrays that are stored there and are JSON encoded, when I get the array I use JSON.parse and to set the array in storage I stringify it. How could this be done to send that kind of data over? Not all the data in localStorage is an array either, there are hundreds of variables in local storage that need to be saved.</p>
  
  <p>EDIT:</p>
  
  <p>Here is my code since it was brought to my attention that it is needed. 
  I am trying to get all the data from localstorage to be sent to the server to be saved in a database.</p>
  
  <pre><code>function postData(){
  
      var storage = JSON.stringify(localStorage);
  
      var xhr;
  
      if (window.XMLHttpRequest) {
          xhr = new XMLHttpRequest();
      }
      else if (window.ActiveXObject) {
          xhr = new ActiveXObject("Msxml2.XMLHTTP");
      }
      else {
          throw new Error("Ajax is not supported by this browser");
      }
  
      xhr.onreadystatechange = function () {
          if (xhr.readyState === 4) {
              if (xhr.status === 200 &amp;&amp; xhr.status &lt; 300) {
                  document.getElementById('div1').innerHTML = xhr.responseText;
              }
          }
      };
  
      xhr.open('POST', 'Membership.php');
      xhr.setRequestHeader("Content-Type: text/json", "application/x-www-form-urlencoded");
      xhr.send("data=" + storage);
  
  }
  </code></pre>
  
  <p>On the PHP side of things I have</p>
  
  <pre><code>if ($_POST){
  
      $data = json_decode($_POST['data']);
  
      echo "The data" .$data;
  
  }
  </code></pre>
  
  <p>I don't know if this is correct, I can't find anything on how to pass all localstorage data, this is basically what I was trying to ask before but obviously failed to convey that. </p>