PHP Cookie not working -
i have following code:
if ($_cookie['lightbox'] != "1") { setcookie("lightbox", "1", time()+3600); echo(" <script type='text/javascript'> if (window.addeventlistener) { // mozilla, netscape, firefox window.addeventlistener('load', windowload2, false); } else if (window.attachevent) { // ie window.attachevent('onload', windowload2); } function windowload2(event) { displaylightbox(); } </script> "); }
what i'm trying accomplish run displaylightbox() once each user using cookie. reason, i'm getting each page i'm going on website, except when ctrl+f5 page. after using ctrl+f5 no longer lightbox. ideas?
it seems first time when cookie isn't set, event added window (unless ctrl+f5) , hence on every page-load, invokes displaylightbox()
.try cancelling event in else part of if.
alternatively, try changing js code this:
if ($_cookie['lightbox'] != "1") { setcookie("lightbox", "1", time()+3600); echo(" <script type='text/javascript'> displaylightbox(); </script> "); }
hope helps.
Comments
Post a Comment