Question

I'm makin a small adventure game and I'm using jQuery Cookie to save some variables (like the amount of the money the player have) in cookies. I know there are tools for cookie managment and editing. Is there a way to avoid editing? Is there a way to camouflage the value/variable corresponding to the total amount of money the player has?

What I have for now is:

<style>
 gold = 150;
 myCookie = { totalGold: gold };
 $.cookie(filename, $.param(myCookie), { expires: 9999 });
</style>

Thanks.

Was it helpful?

Solution

The simply answer is that you can't, Cookies are meant to store references to your session on the server, you can store as much as you want on the client but you have to be aware that it will be apt to be edited, another alternative is to store encrypted values and translate them with an algorithm, that way if the user modifies the value, then it probably won't make sense as the value will be wrong. What you would probably want is to build a JS model that can sync with a server and add some back end logic to validate, you can check out backbone.js

Remember, cookies are stored on the users's computer hence they can do whatever they want with them

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top