Welcome Guest, Not a member yet? Register   Sign In
View counter / Download counter
#1

[eluser]ImmergeTech[/eluser]
How do you securely increase the view count and download count fields for a row such that if you refresh the page 20 times or clear your session and refresh again the view count does not go up?

On my site its possible to keep clearing the session and refreshing over and over to increase the view and download count.
#2

[eluser]tomdelonge[/eluser]
You could check against an ip address. Of course it's always possible for someone to use a different computer or get a new ip. It's at least harder than deleting a cookie...

You could also have someone have to be logged in. Then check against the logged in user. Of course they can have multiple accounts probably, but if you use all 3 methods (ip, session, logged in user) you should be able to detect most duplicate accounts and such.

I've come into this problem myself and never really found a better solution than what I just said...
#3

[eluser]ImmergeTech[/eluser]
Let's assume there are 500 users on this site at any given point, and the site is anonymous (there is no login system).

How would you store ip addresses without ending up with an enormous table in SQL? Run a cron job that empties the table every week or something?
#4

[eluser]tomdelonge[/eluser]
Just do garbage collection like the session class.

Basically, you could have an ip_address column and a ip_date column.

Then every request on a certain function would get some probability. You could have it be 1 out of 100 chance or something. Then every 100th request (basically, give or take a few since it's random) clear out all rows older than a certain timestamp (a week if that's what you want).

Or you could use a cron job if you want...




Theme © iAndrew 2016 - Forum software by © MyBB