Forum Moderators: coopster
At the moment, I am thinking of recording IP addresses in an XML document for each page using SimpleXML, and checking that. My issue is obtaining definite IP addresses for this solution. Currently I am checking IP's using:
/* Get IP Address of User */
if(!empty($_SERVER['HTTP_CLIENT_IP'])){
//check ip from share internet
$ip=$_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
//to check ip is pass from proxy
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip=$_SERVER['REMOTE_ADDR'];
}
Can someone confirm whether this is actually working, because I have a feeling this is not going to work for work groups with the same IP address being used by multiple users, thereby skewing my results.
Thanks in advance.
However you can use IP address to get results (so the problem is with how accurate you want, not the method of obtaining results). These will not be 100% accurate, but they are an easy way to track visitors. If you require an accurate track of visitors then you would need to use something like a session for each visitor.
The answer to your question lies within it.
so as to avoid someone just refreshing a page multiple times thus skewing the results.
So the questions you need to answer is:
How accurate do you need?
Is it important if people can skew your results?
If your results are used for marketing then if a few people refresh there page then that will skew your results by 0.1%, not a problem. If you are running a pay per click (and you are doing the paying) then it is more important.
I have actaully trialled a cookie based solution, which is highly innacurate so far, and thought that the IP solution would have been the go. Considering your advice, my issue with a Session based solution would be that for each person who accesses the site (remembering that they are not logged in), would be given a session id for a particular session, but upon returning to the same article at a later date after closing the browser, would register a second page view on that page with a new id, unless I can store a reference to their session id in a cookie or something, which I would not be favourable of.
Unless I am missing something, is this the most accurate solution possible, because I am trying to get something very accurate.
Your help would be appreciated. Thanks.
Just curious... with your chosen method (using a Session), how are you achieving this? I would have thought you would require some kind of persistent cookie in order to remember the session/user?