Re: Getting and storing user IP address
| From: | Jeffry Killen | Date: | Tue, 24 Mar 2015 07:26:00 +0000 |
| Subject: | Re: Getting and storing user IP address | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-324705@lists.php.net to get a copy of this message | ||
On Mar 23, 2015, at 9:16 PM, Sean Greenslade wrote:
On Mon, Mar 23, 2015 at 12:18:35PM -0400, michael bredthauer wrote:You could also do some experimenting and record all three of the above into some kind of custom log and analyze the logs occasionally to see if there is a reliable pattern. I'm not sure about this but if a client is sending requests for web content and has an ISP that uses DHCP to assign it ip addresses, the apparent address will be the ISP's assigned address, or a proxy address for routing back to the client, in which case only the ISP will know the clients real address (as assigned ) It seems that the rule on the web is caveats abound. I hope this sounds useful JKI have been having some trouble with creating a way to store an IP address of a site visitor for tracking users site visits. So far I have heard using: $ip = $_SERVER['REMOTE_ADDR']?:($_SERVER['HTTP_X_FORWARDED_FOR']?:$_SERVER['HTTP_CLIENT_IP']); Would you consider this the best way?What, specifically, is the issue you're having? I remember (years ago) dealing with a spambot that didn't return an IP in $_SERVER('REMOTE_ADDR'], and my solution was to block clients that didn't have that value set. But if all you're doing is counting visits, you may be better off just parsing your webserver access logs. --Sean