0

I need to be able to track views because people can gain an unfair advantage on my website by faking views.

My current plan is to create a table called VIEWS and use that table to track IP addresses.

$_SERVER['REMOTE_ADDR']

Is it possible for someone to fool this system, by changing IP addresses constantly?

If IP addresses won't work, how do I verify that views are valid?

I'd like to add as well that this is for a high security application. Where fake views could generate earnings.

Amy Neville
  • 10,067
  • 13
  • 58
  • 94
  • 1
    Well, what about multiple users on the same IP? - Your question is rather hard to answer as it depends on what conditions you want to apply – Epodax Nov 30 '15 at 12:02
  • They can be counted as the same user. In this case I'm not bothered by that :) – Amy Neville Nov 30 '15 at 12:05
  • Yes, it is possible to fool the `REMOTE_ADDR` value. If all you are doing is monitoring unique views of a page, then this should be OK (although cookies would be a better way of doing it). Don't rely on it for anything relating to security. – Geoff Atkins Nov 30 '15 at 12:13
  • @GeoffAtkins So, if they could earn money from views it wouldn't be secure then? – Amy Neville Nov 30 '15 at 12:15
  • 1
    I would use a either cookies or sessions, or a combination of the two - in conjunction with IP address + `user agent`. The trouble with IP addresses is that you can have thousands of connections through the same IP address (proxies, VPNs, phone networks), but most people can simply change their IP simply by reconnecting their connection to their ISP. For more information on actually faking the `remote_addr` value; see this question: http://stackoverflow.com/questions/5092563/how-to-fake-serverremote-addr-variable – Geoff Atkins Nov 30 '15 at 12:19

1 Answers1

0

I currently use the Views table approach but if you know your way around cookies, I think you can better recognize distinct views with it.

scylla
  • 124
  • 9
  • how would I do it using cookies? – Amy Neville Nov 30 '15 at 12:14
  • Here is the idea pending time i can put up the script. 1. Check if a visitor has your id tag from your cookie table. 2. if user doesn't have, Set a unique id tag i.e name or code number into a cookie for the visitor's device and at same time post this tag name to your cookie table and you can record your view count for this visit. 3. whenever a user comes. check if he has that tag. if he has, don't count view. if he doesn't have, create a cookie tag, post to dbase and count. – scylla Nov 30 '15 at 12:35