Show Popup And Reset Timer On Refresh
I am showing a popup for users that are not logged in. I do this using javascript and PHP.
Solution 1:
I got the answer from my self with the help of my friend .The cookie should set like below
<?php
setcookie("visited",true);
if(!empty($_COOKIE['visited']) && $_COOKIE['visited'] == true)
$popup_time = 0;
else$popup_time = 60000;
?>
Here $popup_time variable is set to the function javascript code like below
setTimeout(function() {
// Show popup3 after 2 seconds
showPopup(3);
}, <?phpecho$popup_time?>);
And that's it :) . I am frustrated that no one given me a right way here.
Anyway thanks
Solution 2:
Here the idea on how can you achieve this.
- user open the page
check if a cookie
is_first_time
is set2a. if not set show the popup after 5 minutes and set the
is_first_time
cookie 2b. if already set show the popup instantly
Post a Comment for "Show Popup And Reset Timer On Refresh"