Next.js Discord

Discord Forum

Making a game

Answered
Arinji posted this in #help-forum
Open in Discord
So I am making a game in nextjs and I decided to keep the game data in an http cookie. So I made a few server actions to update the cookie etc. But all these post requests are getting kinda hacky. Is there a better way to do this? Maybe redis or smthn
Answered by B33fb0n3
normally when creating a game for public people you want to create a database and put the numbers/settings/data in general, there. So create a database, make a users table and put the userId (maybe with a secret) in the cookies. Make sure to give your user a secret so only the user can update it's own entry (and that without any login/password)
View full answer

5 Replies

@Arinji So I am making a game in nextjs and I decided to keep the game data in an http cookie. So I made a few server actions to update the cookie etc. But all these post requests are getting kinda hacky. Is there a better way to do this? Maybe redis or smthn
normally when creating a game for public people you want to create a database and put the numbers/settings/data in general, there. So create a database, make a users table and put the userId (maybe with a secret) in the cookies. Make sure to give your user a secret so only the user can update it's own entry (and that without any login/password)
Answer
i have done the cookie stuff already, so i just created a games table, with a foreign key to link to the user
its actually so much better this way :D
sounds great