PHP Black Jack game; updating display
my first question on stackOverflow! Have read tons of useful tidbits on here, but haven't been able to find a useful answer to the following question.
I've written a blackjack game in PHP as a learning experience in OO PHP开发者_运维百科. I have one main object which contains the details of all the cards and the game state, I serialize this and save it to a file however this will cause conflicts when more than one person is playing at the same time. I've looked into sessions and saving this data there, but wonder if I need to generate special session id's etc. How do I
Also, there might be a good solution to this problem I haven't considered. Thanks in advance.
What I'd do is use a database for this matter. You shouldn't use sessions to save the game state since it will require all players of the game to have the same data, thus, you will need to duplicate every player's data and save it in the other player's session.
Use sessions to authenticate and know who is who when you're trying to access data from your database
精彩评论