How to store information in a remote storage?

Asked

Viewed 41 times

0

How can I store an entire number that when the user clicks on the button it is incremented only by section (for this I use the sessionStorage) but this incremented value is visible to everyone on the internet, not just in the cookie. This is the code I use:

function clickCounter() {
   if(typeof(Storage) !== "undefined") {
      if (localStorage.clickcount) {
         if (!sessionStorage.voted) {
            localStorage.clickcount = Number(localStorage.clickcount)+1;
         } else {
            jaVotou()
         }
      } else {
         localStorage.clickcount = 1;
      }
         sessionStorage.voted = 1;
         document.getElementById("result").innerHTML = countString();
         document.getElementById("botao").innerHTML = "<center><button onclick=\"clickCounter()\" class=\"myButton\" type=\"Button\">Obrigado</button></center>"
      } else {
          document.getElementById("result").innerHTML = "Navegador não suportado";
   }
}

But when clearing the browser navigation data these values are cleared. How do I make it not occur?

  • What server-side language are you using? Or, remotely you mean, the "browser"? ... If it is, there is no way to persist information in the user’s browser, without it being able to delete, somehow.

  • I want make some storage on the site, I’m using traditional Javascript (I don’t know which :P)

  • To store something on the "site" server, you need to use a server-side language. For example: PHP, Java, Asp... These languages allow you to receive information from those who are accessing your site, and record this information in a database, or even in files.

  • How do I do that? I’m learning web development...

  • So, learn PHP(Which is the most common and perhaps the simplest). There are several tutorials out there. Give a search.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.