You can do that in PHP, I just don't know why you wouldn't use the JS anyway since its required to show the code.
Looks like it'd do the trick. Server languages tend to limit their reliance on cookies as much as they can.
$iDuration = 5;
$bShowIt = !isset($_COOKIE['lastShown']) || isset($_COOKIE['lastShown']) && (time() - $_COOKIE['lastShown']) > $iDuration ? true : false;
setcookie('lastShown', time(), time() + $iDuration);
// do whatever you gotta do to show it
printf('Show something every %d seconds', $iDuration);