O'Reilly logo

Wicked Cool PHP by Brian Ward, William Steinmetz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

#61: Extracting Client Information

Webservers can extract information about their connecting clients by looking at TCP/IP status and HTTP headers. You can access the client's IP address and browser version fairly easily through PHP variables. However, like almost anything the client sends you, this information is completely useless for session tracking. IP addresses aren't unique because of proxies and Network Address Translation (NAT), and browser versions can be completely bogus.

This information is, however, good for finding basic statistics about your users. A few bogus headers here and there aren't going to matter if you're looking at 100,000 accesses.

The following function extracts an IP address. The first part is relatively simple, because ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required