12-08-2007, 07:02 AM
|
#7 (permalink)
|
|
The Wanderer
Join Date: Nov 2007
Posts: 20
Thanks: 1
|
PHP Code:
if(!isset($_COOKIE['last_displayed'])) {
setcookie('last_displayed', "1", 0, '/');
} else {
if ($_COOKIE['last_displayed'] == "1") {
setcookie('last_displayed', date("Y-m-d h:i:s"), time() + (24 * 3600), '/');
echo 'Show Advert';
}
}
Basically you set the cookie on the first pageview to a control value, say 1, and to expire at the end of the current session, so if the user leaves the site after that first pageview if they comeback later that day they will again see the ad on the 2nd pageview.
If the cookie is set to 1, show the ad and set to another value, with an expiry in 24 hours.
Mubs
|
|
|
|