trying to track where my visitor comes from using php
$referal = mysql_real_escape_string($_SERVER['HTTP_REFERER']);
I would like to store this the first time the visitor comes to my site through a r开发者_运维百科eferer. so when this page is accessed again, the variable will not change.
You can store it in a database combined with the IP-address of the visitor. Next time the visitor drops by, you check if the IP-address is known and if it does, just not add it again.
You could extend this by adding the time of the last visit and after a day or something you can add a new record for the visitor. This way you have a very simple visitor counter.
Put it in the session:
$_SESSION['referrer'] = $_SERVER['HTTP_REFERER'];
精彩评论