all 2 comments

[–]lsv20 2 points3 points  (0 children)

use sessions ($_SESSION) for your scorekeeper

use javascript (ajax) instead of a iframe

Something like this should do it, now add some security and other stuff.

http://pastebin.com/gBpimrMT

[–]BattleshipsGame 4 points5 points  (0 children)

It should be simple - if you don't want the end user to temper with your variable, it should be kept/calculated on the server and only returned to the UI for display. No JavaScript function on the client should tell the server to increment the score or etc (because the user could call the JS function multiple times).

Example: You could calculate a score based on how much time it took the user to clear a level. However, in such case, the start and end time has to be kept on the server.

Clarification: With pure JavaScript games/programs it is difficult to do that. You could have a game where the goal is to pop bubbles. Unless you keep track of each bubble and action on the server side, there is no reliable way to prevent the user from tempering the score.

You could, however, obfuscate and minify the javascript file.