Entry
Is there a way to determine the first time a page loads?
Feb 27th, 2008 23:58
dman, Mirek Rusin, John Marc, Brent McLaughlin, http://www.ttnr.org
By 1) referer, 2) cookies, 3) session:
1) Referer:
$ref_host = parse_url($_SERVER['REFERER'])['host'];
$my_hosts = array('mydomain.com', 'www.mydomain.com');
if (!in_array($ref_host, $my_hosts))
echo 'First page load!';
else
echo 'Not first page load!';
2) Cookies:
if (!isset($_COOKIES['not_first_load'])) {
echo 'First page load';
$_COOKIES['not_fist_load'] = true;
} else {
echo 'Not first page load';
}
3) Session
Same as with cookies.
Mirek Rusin,
http://crystalsoft.biz