> in order to prevent my visitors from seeing more than one popup in less than
> 120 second, I added this to my php page(index.php)
> --------------
> setcookie("popup",1,time()+120);
> if ($popup!=1)
>
>   echo "<script src=http://www.peel.net/frames/PMNforce.js></script>";
> }
> -------------
>
> When I reload index.php, i see popups everytime. I am pretty sure that I
> enabled cookies in IE and Netscape.
>
> Please help. thanks

Do you really think that people will have their system clocks set
accurately to within 120 seconds of your server's system clock?  Heck, you
are lucky if they have their clock set to the right year, never mind the
right date and time down to the minute.

To do this reliably, encode your system time in the cookie value and use
that to determine whether the cookie is valid.  And use a session cookie.
Like this:

$value = 1;
$time = time() + 120;
setcookie('popup',"$time:$value");
if(isset($popup)) {
        list($time,$value) = explode(':',$popup);
        if($time > time()) $popup = false;
        else $popup = true;
}

if($popup)
        echo "<script src=http://www.peel.net/frames/PMNforce.js></script>";

-Rasmus


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to