0

Here's my problem: I want to show the user a hash from a random number, then that user has to guess if the number is higher or lower than a certain treshold. After the game, I want to show him the number so he can verify that the number has not changed during play.

But how do I do that? I have thought about using Redis to store the random number and the user id in there, but it seems like there are easier solutions.

Thanks!

Edit: In the end I chose Redis because it's server side only for maximum security and I may find some additional uses for it.

pgrosslicht
  • 1,552
  • 13
  • 18

1 Answers1

2

You could use a "signed" cookie. This prevents the user to "look" at it, and gives no overhead

See http://api.rubyonrails.org/classes/ActionDispatch/Cookies.html

To write:

cookies.signed[:guess] = guess

To read:

cookies.signed[:guess] 
Danny
  • 5,945
  • 4
  • 32
  • 52
  • I did not know about those, thanks. How safe are they? I can't find that much information about them. Edit: But couldn't the user save the cookie and then send the cookie with the next game to get the same number as before? – pgrosslicht Jan 09 '14 at 08:14
  • They are safe in that a user can't "read" them. They could copy, but, by deleting any "pending" cookies before you start a new game, by deleting it immediately after he "solved" the game, you should be pretty save – Danny Jan 09 '14 at 11:59