1

Using PHP and MySQL:

Considering that two computers can share an IP address if they somehow use the same server. What's the better method to identify each machine and allocate it one count within 24 hours. Meaning a single machine can only increment view counts once every 24 hours regardless of how many views within this 24 hours.

aug born
  • 248
  • 1
  • 3
  • 20
Relm
  • 7,923
  • 18
  • 66
  • 113

1 Answers1

4

That depends of the goal that you want to achieve. If this is some sort of non-necessary information (i.e. 'good to have it, but if not - then ok'), then you can use cookies or sessions. I.e. you should set a cookie with 24 hours lifetime and at each visit you should check if it is set.

But: if this data is mandatory, if it is a way for you to restrict something or - more - build some security, then the answer will be: no way. Client can always send fake data to overcome any possible restriction. Cookie is just an optional HTTP-request parameter (and it can be deleted, yes). The only more or less solid parameter is IP-address, but, however, it can be changed with proxy-servers too.

Conclusion will be: you know nothing about your visitor. This is a rule, when you're dealing with web-application.

Alma Do
  • 37,009
  • 9
  • 76
  • 105