Page 1 of 1

getting info from browser

Posted: Fri Sep 09, 2005 4:30 pm
by jaymoore_299
can someone show me a simple code of a code that will print out the ip address, the http referer and the language of the browser of the user currently viewing the page?

Posted: Fri Sep 09, 2005 4:36 pm
by feyd
  1. $_SERVER['REMOTE_ADDR']
  2. $_SERVER['HTTP_REFERER'] (may or may not exist)
  3. $_SERVER['HTTP_ACCEPT_LANGUAGE'] (may or may not exist)

Posted: Fri Sep 09, 2005 6:00 pm
by Roja
Don't forget that #1 might not be set, or be accurate. They could be going through a proxy, a web aggregator, a national filter, or dozens of other situations.

Read my sig to grasp the point.

Posted: Fri Sep 09, 2005 6:07 pm
by deltawing
Roja wrote:Read my sig to grasp the point.
Just one comment about your sig, which I thought of a little while ago. On livejournal.com, they have an option that you can set when you log in (as a sub option of "remember username and password") of "bind to IP address", which they reckon is safer if you have a static IP (no need to store password in a cookie). So there sometimes is a relationship, but the only way to know is if a user specifically tells you himself.

Posted: Fri Sep 09, 2005 6:12 pm
by Roja
deltawing wrote: Just one comment about your sig, which I thought of a little while ago. On livejournal.com, they have an option that you can set when you log in (as a sub option of "remember username and password") of "bind to IP address", which they reckon is safer if you have a static IP (no need to store password in a cookie). So there sometimes is a relationship, but the only way to know is if a user specifically tells you himself.
Nope. Even then, the user's IP could change completely outside of his control. Netmasks change and get reassigned, natural disasters can hit and restructure router tables, DHCP servers reset, the list goes on.

There is no reliable relationship between a user and an IP. Its useless.

Posted: Fri Sep 09, 2005 6:23 pm
by deltawing
I'm not going to argue with you too much there, because I've never used the IP address for anything, and I doubt I ever will, but for non-critical tasks, if a user says his IP is static, its his problem if it changes, and even then, its not really a problem (non-critical, remember). All he would have to do is log in again to change it to the new IP. I'm not disagreeing with you, because I know there are plenty of people out there who value the IP address too highly (I was one of them a long time ago, except then, I didn't really know how to do anything with it). Its just a point that you can find a use which works 95% of the time.

Posted: Fri Sep 09, 2005 6:28 pm
by Roja
deltawing wrote:Its just a point that you can find a use which works 95% of the time.
Thats exactly the point I'm arguing is completely inaccurate. Its not even close to 10%.

The vast majority of users change IP's in a SINGLE SESSION, thanks to the power of AOL and work proxies. The situation you describe, where a user knows their IP will remain static, is at best 10% of the IP population, just due to how ip addressing works. Then add in random factors (hurricanes, reassignments, losing their job and thus their ISP..), and suddenly, the statement "The IP has a relationship to the person" drops below 10% too.

Of course, you could by extension say that people guessing numbers will win the lottery 95% of the time. Wouldn't make THAT any more accurate by saying it. :)