Every now and then you may want to access some information about a website visitor. You might want to provide this information to them or perhaps you want to display different text, images, etc. depending on what host they are from. This article highlights using some simple php code to retrieve visitor info such as ip address, hostname, browser type, etc. The following $_SERVER variables give you access to this information -
IP address of visitor:
$_SERVER['REMOTE_ADDR'] =
38.107.179.207
Hostname of visitor:
gethostbyaddr($_SERVER['REMOTE_ADDR']) =
38.107.179.207
Port used by visitor:
$_SERVER['REMOTE_PORT'] =
60872
Software used by visitor:
$_SERVER['HTTP_USER_AGENT'] =
CCBot/1.0 (+http://www.commoncrawl.org/bot.html)
Referring page:
$_SERVER['HTTP_REFERER'] =
Page Request Timestamp:
date(DATE_RFC822, $_SERVER['REQUEST_TIME']) =
Sun, 20 May 12 09:17:21 -0500