I've been searching for the last hour how to do this... I think it's pretty easy, but couldn't make it work.
I want to show something (AdSense) only once per day.
I don't know what would be the best way, if using cookies or PHP Sessions. In any case, can you help me and tell me how could I do this?
Thanks in advance!
Santiago
Edit: I think this way I can create the Session, but I don't know how to "recreate" it each 24 hours and how to check for that session in order to show what I want to show once a day.
if (!isset($_SESSION['adSense'])
$_SESSION['adSense'] = time();
if (time() - $_SESSION['adSense'] <= 60*60*24 ) {
return true;
} else {
return false;
}
Sessions will expire when the user leaves the site, using cookies is what you want:
<? if (!isset($_COOKIE['showstuff'])): ?>
<!-- replace this whatever you want to show -->
<?
setcookie('showstuff', true, time()+86400); // 1 day
?>
<? endif; ?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With