How would you have solved this task (ad rotation of two types)?

There are two types of advertising:
1 - registered.
2 - affiliate advertising is from google, yandex, etc.
Rotation 2 (customized) 4 (partner).

When the client(unique ip) addressed to the server, the server must issue the order is, if a second time appealed again, all the rotation of ads is over, then there are affiliate advertising for the trail. circulation. And so the circle.

There is an idea to implement this using the tables in the database where are recorded the ip addresses and their current type of advertising and number of screenings. Want to know how you'd implement it, maybe someone knows easier way.

How do you think whether correct this problem ? because I think that some users will have a common Internet service provider and the Internet provider will be a single ip address for all their customers.
June 14th 19 at 21:06
1 answer
June 14th 19 at 21:08
Use of cookies.
Database and stuff is only needed for extra dimensions, so if you need it and be screwed.
And so write in a cookie the number of views for ads, and when a user logs in based on the value and choose what to show.
yeah, forgot about the cookies. - brook.Dare commented on June 14th 19 at 21:11
only use signed cookies - marilyne_Roh commented on June 14th 19 at 21:14

Find more questions by tags AlgorithmsDjango