|How I get IP address of client, previous reference page etc ?|
| 10:48 am on Nov 30, 2011 (gmt 0)|
How I get IP address of client, previous reference page etc ?
Plz Help me anyone?
| 4:54 pm on Nov 30, 2011 (gmt 0)|
with php it very easy to get user info using the server variables:
all you need is here and more:
| 4:55 pm on Nov 30, 2011 (gmt 0)|
change second $ip to $referrer or what ever you want to call it.
| 4:57 pm on Nov 30, 2011 (gmt 0)|
Look through the list of $_SERVER [php.net] variables (environment variables in most other languages) or print a phpinfo() to see them.
The referrer is only sent if a link was actually clicked, it is not present in direct requests, and it not all that reliable - only sends if the client (in this case, browser) sends it, which some don't, and can be disabled for security purposes. But in most cases it's useful.
"Client" can mean many things. In web apps, it means the software accessing the resource, which for most of us is a web browser. If you mean your customers, it's a different context.
The remote_addr value will report an IP address, but that IP address is not actually the "client's" computer, it's the IP assigned to the modem by the internet service. It's also unreliable - in may cases these are assigned dynamically, that is, if you restart your modem, the ISP may assign a different IP to the connection. WiFi changes everything too, you can access via different networks easily.