Jump to content
  • Advertisement
Sign in to follow this  
Legendre

Cookies for keeping inventory? (PHP + MySQL RPG)

This topic is 2505 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I learned some PHP + MySQL recently and wrote a simple text "choose your own adventure" game. Basically the entries are stored in a MySQL table, and the website displays the content of the entry. For each entry, players get to pick with entry to go to, which causes the website to display the content of the entry they chose. So far so simple.

I was wondering if it was possible to implement a simple inventory for my game using either cookies or sessions? For example, when the "Door" entry is displayed, the cookie is checked if it contains the "key". If the key is present, a button labeled "open Door" is created, which allows player go to an entry they could not have gone without the key.

Thanks for any input. smile.png

Share this post


Link to post
Share on other sites
Advertisement
It's probably better to just have a cookie identifying the session and then store the inventory in the database. If you put the inventory in the cookie, it would be pretty trivial to hack and present a manufactured cookie that has the key.

Share this post


Link to post
Share on other sites
Less important might be the fact when the player cleans his browser history his items are gone. And the most beutifull thing of internet games is gone as well, the oppertunity to play the game wherever you want.

Use mysql, it's been made for that.

Share this post


Link to post
Share on other sites
Thanks for the advice guys. I am going to use sessions instead. I know everything gets wiped when the player leave the website. But I only need to keep track of a few items (a key to the door for example).

This is my first web game project, meant to be a short game, so I will keep it simple for now. For my next game I will make a login system and store characters in MySQL for some persistence.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!