getting info from browser

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jaymoore_299
Forum Contributor
Posts: 128
Joined: Wed May 11, 2005 6:40 pm
Contact:

getting info from browser

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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)
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post 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.
deltawing
Forum Commoner
Posts: 46
Joined: Tue Jun 14, 2005 2:55 pm

Post 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.
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post 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.
deltawing
Forum Commoner
Posts: 46
Joined: Tue Jun 14, 2005 2:55 pm

Post 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.
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post 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. :)
Post Reply