I need to keep a counter for a game that I am making. Each time they win a game, I want to add one to the counter. However, each time they win, the page is refreshed to start a new game. Is there a way to keep this counter updated even if the page is reloaded?
Share
You can use cookies, here’s a very simple example with jQuery cookie plugin:
Code: https://github.com/carhartl/jquery-cookie
Usage examples: http://www.electrictoolbox.com/jquery-cookies/
Set cookie:
Get cookie value:
Very clean and compact 🙂