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.206
Hostname of visitor:
gethostbyaddr($_SERVER['REMOTE_ADDR']) =
38.107.179.206
Port used by visitor:
$_SERVER['REMOTE_PORT'] =
54478
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']) =
Mon, 06 Feb 12 10:15:02 -0600
Add new comment