For every relevant action users perform on a site (posting comments, voting, reporting/flagging, etc.) I store his IP and host name (retrieved from PHP function gethostname() - doc). I have copied this idea of storing the host name from a WordPress rating plugin.

I thought that if a well known plugin is doing this, it is because that info is somehow useful when moderating comments or avoiding poll manipulations. But now that I'm redesigning the site and the database structure, I start to question if this info is really useful.

Is it normal to keep this info? Should I keep it or just drop the column?

  • Why do you even keep the IP number? Since most people have a dynamic IP it isn't particularly useful for tracking a single visitor. Should someone post something bad or try to run a script, are you REALLY going to track the IP and then what? I challenge you to get around privacy laws and the like to discover an identity without some sort of court order.
    – Steve
    Aug 17 '14 at 7:18
  • You don't need to find out who owns an IP to report abuse. You can easily find out which ISP an IP belongs to and report abuse to them. Aug 17 '14 at 8:07
  • @Steve what Tim said. I already had to report an IP and it worked.
    – rlcabral
    Aug 17 '14 at 16:38

You should not do this. It is a bad practice for website to do host name lookups for each visitor as it uselessly taxes DNS servers. Keep the IP, not only because it is useful if you need to report something to an ISP (such as a DOS attack or the like) but also because it is useful when you need to cross reference your DB logs with your web server access logs. The only information you're going to really get from having a hostname is the ISP and that is only by convention. An IP lookup service will help you figure out the rest if you need to. Even though IPs may change for specific users fairly often; the information provided by these services doesn't really change that much because those addresses are still reserved for the same ISP. Just keep in mind that at any time multiple (unrelated) users may share the same IP from your servers perspective and a single user may use a different IP at any time so these are only hints as to what is going on (but knowing the host name doesn't clear things up at all because this is information you could easily look up at any time it is needed).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.