I am new to javascript and jQuery. I am using SimpleModal basic to display a popup onload when a user visits my site. It's working great, but each time visitors go to homepage, the popup displays.
For example:
- Visitor A goes to my homepage, the popup displays for the first time - it's great
- Visitor A goes to a page inside my website, and click on logo to come back to homepage, the popup displays for the second time, and keep showing each time visitor A back to homepage - it's not good.
I need this popup to be displayed only once per session.
I have searched all over the internet, and have seen that this can be taken care of using a cookie, but I'm not sure of how to tie the cookie function into the function of the modal script.
How can I implement a cookie to track the modal function, and display it only once when the page loads?
Here is the script that loads the modal content:
<?php if($_SERVER['REQUEST_URI'] == '/'): ?>
<script type="text/javascript" src="<?php bloginfo(template_url);?>/assets/javascripts/jquery.leanModal.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('#basic-modal-content').modal();
});
</script>
<?php endif;?>