[PHP] Realizzare uno script che informa il visitatore della sua ultima visita sul sito!
Posted on 06. Nov, 2009 by daniele in php, tutorials
Questo script permette di riconoscere se il visitatore è la prima vola che visita il sito, se l'ha visitato più volte nella stessa giornata o se lo visita ogni giorno. Per far si che il nostro script riconosca le visite dei nostri utenti abbiamo bisogno dei cookie che salveranno sul PC del visitatore la data e l'ora della visita!
< ?php if(isset($_COOKIE['AboutVisit'])) { $last = $_COOKIE['AboutVisit']; } $year = 31536000 + time() ; //this adds one year to the current time, for the cookie expiration setcookie(AboutVisit, time (), $year) ; if (isset ($last)) { $change = time () - $last; if ( $change > 86400) { echo "Welcome back! You last visited on ". date("m/d/y",$last) ; // Tells the user when they last visited if it was over a day ago } else { echo "Thanks for using our site!"; //Gives the user a message if they are visiting again in the same day } } else { echo "Welcome to our site!"; //Greets a first time user } ?>




Leave a reply