hi,
i am new to php and i know that i should be able to use cookies to help me only let a window to popup once per session (or 10 minutes).

all i need to do is check if the cookie is present and then either popup the winow or not.

if anyone has the code to this simple (i think) question, please let me know.

SUMMARY:

  • when a person comes to the home page of the site. window should pop up.
  • when a person returns to the home page, the window should not pop back up, unless 10 minutes has passed.

thanks

    Put this at the top of your page:

    <?
    if (!isset($popup)) {
    put javascript for popup here
    } else {
    setcookie('popup','set',time()+600);
    }
    ?>

    I think that should work...
    just remember to include your javascript for your popup.

      Surely you know you can't mix executable PHP and javascript. The entire part of detecting the cookie also has to be JS. See javascript.internet.com for some working demos.

        Sorry.... forgot to exit out of the php code.

        <?
        if (!isset($popup)) { ?>
        put javascript for popup here
        <? } else {
        setcookie('popup','set',time()+600);
        }
        ?>

          ok, i must be doing something wrong. i have the popup working but no ccokie seems to be set. everytime i close and reload or move from one page back to the popper page, the window keeps popping up and there is no cookie visible in my Cookies folder.

          the link to the test pages is at www.travelfleamarket.com/Poptest

          thanks for the help.
          bill

          ps. i am very new to this.

            Well... first of all, you have the file named 'index.html'.

              yes i am a mellon....

              but what does that (the file named index.html) have to do with it?

                Please read the manual or get a book or read some tuts online or something.

                  thanks...i'll try that

                    Write a Reply...