Page 1 of 1

COUNTDOWN - GIVEN in MIN...

Posted: Fri Sep 09, 2005 8:35 am
by poeta_eletrico
Hi,


I read a lot of posts as COUNTDOWN - 25 at all found on my search here. But no ones seems to completly cover a simple question:


1. If the PROGRAMMER needs to have that COUNT on every single page and it s not using an IFRAME or else.
2. When the user get LOGGED IN it´s code records the 'future min to come' into COOKIE and the parse this cookie like:

$expiredate=mktime(date('H'),date('i')+30,0,date('m'),date('d'),date('Y'));
setcookie("living", $expiredate, $expiredate);

$future=split(':',strftime('%T',$_COOKIE['living']));
$now=split(':',strftime('%T',time()));
Displayed METHOD IS: XX min YY sec (used in every page).

When the time has come 00 MIN 00 SEC - I´ll recall an action and UNSET all SESSIONS and COOKIES used and DO LOGOUT to that specific user. I round and round the internet and developed a code but I´m getting in trouble subtracting min by the seconds. I tried to MIX javascript with PHP but I did not find any suitable manner for that.

Can anyone here comment my problem with any TIP or CLUE?

Thanks in advance for all of you.

Bye,
Poeta_Eletrico

Posted: Fri Sep 09, 2005 8:43 am
by anjanesh
I guess Javascript is the only way.
You can try implementing AJAX in this case.
But you cannot stop anyone from not counting down to 0 if the user disables JS for this reason.

Posted: Fri Sep 09, 2005 8:51 am
by feyd
the only thing you can do server-side is store information on a "best guess" of when to expect the response. (Basically, it's the time alotment you want to use plus some extra time for transmission delays and such.) If the time passes, you kill their session and redirect them or display the logged out page instead of continuing.

Posted: Fri Sep 09, 2005 10:15 am
by poeta_eletrico
anjanesh wrote:I guess Javascript is the only way.
You can try implementing AJAX in this case.
But you cannot stop anyone from not counting down to 0 if the user disables JS for this reason.
Hi anjanesh,

Thanks for your response. But as not a programmer (experienced one) - I think AJAX is a little bit out of my scope at this moment. But that´s very interesting to study to and I´ll search for documents related.

Kind Regards,
Poeta_Eletrico

Posted: Fri Sep 09, 2005 10:20 am
by poeta_eletrico
feyd wrote:the only thing you can do server-side is store information on a "best guess" of when to expect the response. (Basically, it's the time alotment you want to use plus some extra time for transmission delays and such.) If the time passes, you kill their session and redirect them or display the logged out page instead of continuing.
Hi feyd,

"BEST GUESS" Sorry but i misunderstood this part :D can u describe it in my newbie language?

I have this portion of code running besides with the DISPLAY COUNTDOWN. That works properly behind the scenes cos is not responsible to SHOW ANYTHING, but just checking out :

Code: Select all

<? if($present < $future){
      echo $mins." min : ".$num4." sec";
}else{ 
      echo "<script type="text/javascript">
<!--
      window.location = "http://myserver.com/?do_logout=yes"
//-->
      </script>";
}?>
Is not necessary to me have a SERVER-SIDE countdown got it? Because as I store my FUTURE MIN TIME to countdown in a COOKIE so I can use CLIENT-SITE and when this time is UP recall the code above, got it?

Thanks for your attention anyway.

Poeta_Eletrico