I would like to make a site where a popup appears once in 24h for every unique user. For this I use bPopup and cookies. I have tried lot of things and for now I am kind of "lost" in the code. Could you help me to make it work how it is supposed to be?
The code:
<?php
if (!isset($_COOKIE["Seen"])){
if ($_COOKIE['Seen'] != 'true') {
setcookie('Seen', 'false');
}
}
?>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"> </script>
<script type="text/javascript" src="js/popup.js"> </script>
<LINK REL=StyleSheet HREF="style/style.css" TYPE="text/css" MEDIA=screen>
<html>
<head> </head>
<body>
<!-- Element to pop up -->
<div <?php if(isset($_COOKIE["Seen"])) {
if ($_COOKIE['Seen'] == 'true') {echo 'style="all:none; visibility:hidden; display:none">';}
else {
echo ' id="element_to_pop_up">';
$value = 'true';
$expire = time()+60*60*24;
setcookie('Seen', $value, $expire);
}
}
?>
<a href="#"class="b-close" style="position:absolute; margin-top:5px; margin-left:550px;"><img src="./image/close.png"><a/>
<iframe frameBorder="0" name="iFrame" width="600" height="500" src="welcome.php" scrolling="no"></iframe>
</div>
</body>
</html>
What about something like:
if(!isset($_COOKIE['popup']))
{
setcookie('popup', time());
echo '<script>alert(\'Here is your daily cookie :)\');</script>';
}
else
{
if((time() - $_COOKIE['popup']) > (60*60*24))
{
setcookie('popup', time());
echo '<script>alert(\'I see you enjoy our cookies, thanks for returning :)\');</script>';
}
}