How not to lose credits in a flash game if it ends suddenly (browser closes)

Hi guys,
i have a program that consists of php (5.3) code, mysql, javascript and it loads flash games. A database with login and user information such as name,credits, last played game, last time played etc. and also game info exists.
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

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.