cookies won't help with the meat of the problem.
You need to keep track of what the current number is, how many times each user has seen it.
A database such as mysql will do this pretty easily.
You need two tables.
The first table contains the current number and it's unique ID.
The second table contains a unique id, the IP of a user, and the index to their number, and a count of number of times that user has seen that number.
Each time a client loads, you look at their IP, you see which number is theirs and then you look at how many times they've seen that number. If they've seen the number less than five times, then you show them the number, and update the number of times they've seen it. After you've updated it, you need to check to see how many people that number belongs to and how many times they have seen it. If the max number of people have seen it the max number of allowed times, you delete all instances of those people and the number from the number table, then you generate a new number and stick it in the number table.
When a new client logs on, you check to see if they have a number, if they dont' have a number, you look to see if there is a number available. If there is, you assign them the available number, and display it and update the number of times they have seen it.
If there is no number available, you insert a new random number in the number table and assign it to them...
This will work, but I've assumed some stuff that you haven't specified. Your needs may not be so complex.