/** * We track visitors to the website by setting a unique ID string into * a cookie. */ private function setTrackingCookie() { if (!isset($_COOKIE['u'])) { // create a unique string $uid = md5($_SERVER['REMOTE_ADDR'] . $_SERVER['REQUEST_TIME']); // expire 6 months in the future $expires = time() + 60 * 60 * 24 * 30 * 6; $domain = Cookies::getThisDomainName(); setcookie('u', $uid, $expires, '/', $domain); } }
public function run() { // get the base domain name $domain = Cookies::getThisDomainName(); // clear the session cookie setcookie('s', '', time() - 3600, '/', $domain); // refresh the page $url = $_SERVER['PHP_SELF']; $url = str_replace('.php', '', $url); $url = preg_replace('/\\?.*$/', '', $url); if ($url == '/index') { $url = '/'; } header("Refresh: 0; url={$url}"); }