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

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -