How do i use cookies? How do i make it with online capabilities?

I have been working on a clicker game and I was wondering how to use cookies for saved data, like
how do I store the amount of clicks they have earned in the game, how do make it so that others see other people’s scores, and how do i prevent cheating?
If someone could please reach out to me that would be great!

Cool!

I really like incremental games, and I recently followed along on GalaxyKate’s speedrun to make one using Vue: https://glitch.com/~star-muscari

That explains how to use localStorage to save data so you can close the browser and then reopen it - “cookies”.

If you want to have shared state among multiple users then you need server-side persistence, and ~hello-sqlite might be helpful - instead of reading and writing dreams, you would be reading and writing the high-scores table.

Preventing cheating in incremental games is pretty hard; essentially you would record the sequence of choices that the player made (when the player bought what), and you would re-run the simulation on the server-side, but faster. Then you award them, not the number of points that they claim they earned, but the number of points that the server-side simulation says that they earned.

Hope this helps,

Johnicholas

1 Like