My question is this, if someone is playing a game and has x playcredits (which is updated in the db while he is playing), how can i make sure that if the game ends abruptly (the browser closes for example) the x credits will transfer back to the user. At the moment when this happens the player is shown stuck that he is still playing the game.
For clarification the game playcredits remain in the db table that has the game info, so i need them to be transfered back to the user and the game to become unstuck. Basically i don't know if this can happen with the sessions that exist after logging in or simple with a mysql query in an if ...statement. I can't really post anything because my code consists of 125php files, so maybe a general guideline on what to look for or to do will be much appreciated