Exercise : Prize (by Michael Beswetherick)
is a travel site.
We want roughly every 10th visitor to win a "free trip".
()
- Every time the page loads, there should be a 1-in-10 chance that the viewer wins a prize.
- If the user wins, show a congratulation message.
-
Use a cookie to remember whether the current user has won the prize.
If so, on all future page visits give them a link to redeem their prize.
-
Give the user 24 hours to redeem the prize before the cookie expires.
(Test it with very small values such as 10 seconds.)