Holaaa
I wanted to create a simple website containing a button. If I press the button 5 times, it says 5. When I refresh the page, it should still say 5. And when You load the page, it also says 5 and you can go on clicking.
I know how to build a counter for ONE session and one user, but I have nooo idea how to implement it to be stored "online".
I know that I need to implement a database to store the value and load the latest click-value once the website is opened but I dont know where to simply start
CodePudding user response:
You can use localstorage to persist the count.
Example when the page starts:
var cat = localStorage.getItem('miGato');
Example to save the count:
localStorage.setItem('miGato', 'Juan');
The documentation is:
CodePudding user response:
Yes you can use Window.localStorage, Syntaxis
var cat = localStorage.setItem('miGato', 'Juan');