In this program we are saving the number of times that the page has been loaded, but we could use the same technique to store any kind of progress. Processing offers two functions that allow you to read and write to a file loadStrings
and saveStrings
. In this program we are reading and writing to a text file called progress.txt
. The first time a user visits the page, we load the number 1 from progress.txt
and display it to the screen. Then we increment the counter and save the increased value using saveStrings
.
When we save the increased value, it is stored in the users web browser cache, not in the progress.txt
file. This is called HTML storage or Web storage. This means that each users progress will be saved independently of any other users. Note that the size of the stored data is limited to 5Mb.