I have been working on a web based game, in which involves a lot of javascript/PHP. My question is what is the most secure way to handle any data being passed between the two languages?
At this moment I am currently using javascript to preform any required functions such as making objects appear for you to click and then awarding points for clicking that object.
I know javascript isn't the best way to handle the data due to how accessible it is on the client-side. I currently use ajax to pass the points gained from a click, to PHP where it can then assess whether the points were gained fairly or by an exploit.
This works, however when it comes to making sure that the user doesn't abuse a function in the console such as "Spawning an object" I run into some issues, as I can't seem to think/find of a way to achieve this. At the moment I have it so when the game starts an interval begins which displays an object based on a random value and then when the user clicks that object it gets destroyed and their score is sent to a PHP file to check the action was legit.
Is there some sort of way I can make a checker in the PHP file to make sure that an object can only be spawned if the browser calls it and not the client. I know you can't stop a user from using the console, its more of thinking of a system to judge/evaluate whether an action is allowed by a user.