I am using below code to show a popup on my home page. But the problem is that it shows every time a user reloads the page. Instead of that I would like to be displayed once per day. Here is the code: The stylesheet and js.
You would need to make a note of when you show the modal and then every time before you want to show it first check when it was last shown. If it’s less than a day don’t show it.
The easiest way would be to drop a cookie that expires in a day. If the cookie exists, don’t show the popup.
Can you please guide how I can achieve that because I tried below code and didn’t show anything.
<script type="text/javascript">
$(document).ready(function(){ // if the cookie doesn't exist create it and show the modal
if ( ! $.cookie('hereTodayx') ) { // create the cookie. Set it to expire in 1 day
$.cookie('hereTodayx', true, { expires: 1 }); //call the reveal modal var delay=5000; //in ms, this would mean 5 seconds setTimeout(function(){ $("#myModal").modal('show'); },delay); } }); </script>