I have created a splash-video which is played when a visitor visits the page for the first time. With a cookie I can set an expiration time when this splash-video will popup again. What I'd like to achive instead is when this splash-video is played on first visit it will only display again on next visit (when user closes the tab or closes the web browser window).
What I have read while searching, if I don't set an cookie expiration this should work.
setcookie( 'my_cookie', 1 );
The problem is that if user in for example Chrome have settings set to "On Start -> Continue where you left off", this behaviuor won't work.
Is there really a bullet-proof way of achieving what I want?
Kind regards Johan
UPDATE:
This seems to work fine. Any comments on that?
<script type="text/javascript">
if (/(^|;)\s*bvssp_visited=/.test(document.cookie)) {
document.getElementById("demo").innerHTML = "welcome back";
var myVar=setInterval(function(){document.cookie = "bvssp_visited=true; max-age=" + 10 * 1},1000);
} else {
var myVar=setInterval(function(){document.cookie = "bvssp_visited=true; max-age=" + 10 * 1},1000);
document.getElementById("demo").innerHTML = "Hi new user";
}
</script>