Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Page Session Countdown Timer

Reply
Thread Tools

Page Session Countdown Timer

 
 
MC
Guest
Posts: n/a
 
      03-22-2008
I would like to display a timer in the corner of the page that shows the
user how many minutes:seconds till the session times out. Are there any good
examples out there?

Google has again failed me

MC


 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      03-22-2008
MC wrote on 22 mrt 2008 in comp.lang.javascript:

> I would like to display a timer in the corner of the page that shows
> the user how many minutes:seconds till the session times out. Are
> there any good examples out there?


Session is a serverside concept.
Clientside, thee is not such a thing as a session timeout.

> Google has again failed me


Do you want Google to write your programming?
It will cost you!


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
 
 
 
MC
Guest
Posts: n/a
 
      03-22-2008
Evertjan,

I have to say your wrong. A javascript can track every time a page loads,
and knowing the session timeout, calculate an approximate, hopefully +- less
than one second, session timeout.

I would like to, given a timeout such as 30 minutes, have a countdown from
the onload event. It would then be nice to prompt the user to logout or
continue the session by sending a message back to the server to refresh the
session.

I say your wrong, because session timeouts ARE being done currently in many
websites such as banks. ...and I never suggested Google write my code, but
that Google search find an appropriate example.

Please troll someplace else if you have nothing constructive to add.

MC

"Evertjan." <(E-Mail Removed)> wrote in message
news:Xns9A69AE97BA7ECeejj99@194.109.133.242...
> MC wrote on 22 mrt 2008 in comp.lang.javascript:
>
>> I would like to display a timer in the corner of the page that shows
>> the user how many minutes:seconds till the session times out. Are
>> there any good examples out there?

>
> Session is a serverside concept.
> Clientside, thee is not such a thing as a session timeout.
>
>> Google has again failed me

>
> Do you want Google to write your programming?
> It will cost you!
>
>
> --
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)



 
Reply With Quote
 
sasuke
Guest
Posts: n/a
 
      03-22-2008
On Mar 22, 8:16 pm, "MC" <mica[removethis]@aisus.com> wrote:
> I would like to display a timer in the corner of the page that shows the
> user how many minutes:seconds till the session times out. Are there any good
> examples out there?
>
> Google has again failed me
>
> MC


Here is a simple script which you can modify as per your needs with a
little bit of Javascript knowledge.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8" />
<meta http-equiv="Script-Content-Type" content="text/javascript" /
>

<title>Example</title>
<script type="text/javascript">
var t = 10; /* This would come from PHP */
var decr = 1;
var handle = null;
var e = null;
function startTimer() {
if(!e)
e = document.getElementById("time");
e.innerHTML = t;
handle = setInterval(function() {
if(t == 0) {
clearInterval(handle);
/* do what you want when the timer expires */
window.location.href = "http://www.google.com/";
}
else {
t -= decr;
e.innerHTML = t;
}
}, decr * 1000);
}
window.onload = startTimer;
</script>
</head>
<body>
<div>The time remaining is <span id="time"></span></div>
</body>
</html>

HTH
 
Reply With Quote
 
Dr J R Stockton
Guest
Posts: n/a
 
      03-22-2008
In comp.lang.javascript message <Xns9A69AE97BA7ECeejj99@194.109.133.242>
, Sat, 22 Mar 2008 16:09:49, Evertjan. <(E-Mail Removed)>
posted:
>MC wrote on 22 mrt 2008 in comp.lang.javascript:
>
>> I would like to display a timer in the corner of the page that shows
>> the user how many minutes:seconds till the session times out. Are
>> there any good examples out there?

>
>Session is a serverside concept.
>Clientside, thee is not such a thing as a session timeout.


A client can count down for a length of time indicated by the server;
and can occasionally be synchronised with the server's opinion.

>> Google has again failed me


Try "Good countdowns" as your search string.
As a contrast, seek countdowns on .gov sites.

TD09690 : Until 03 September 2081 10:07:31 LCT : 26827d 11h 54m 56s .

--
(c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05.
Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      03-22-2008
MC wrote on 22 mrt 2008 in comp.lang.javascript:
> "Evertjan." <(E-Mail Removed)> wrote in message
> news:Xns9A69AE97BA7ECeejj99@194.109.133.242...
>> MC wrote on 22 mrt 2008 in comp.lang.javascript:
>>
>>> I would like to display a timer in the corner of the page that shows
>>> the user how many minutes:seconds till the session times out. Are
>>> there any good examples out there?

>>
>> Session is a serverside concept.
>> Clientside, thee is not such a thing as a session timeout.
>>
>>> Google has again failed me

>>
>> Do you want Google to write your programming?
>> It will cost you!


[Please do not toppost on usenet]

> I have to say your wrong. A javascript can track every time a page
> loads, and knowing the session timeout, calculate an approximate,
> hopefully +- less than one second, session timeout.


No it cannot, as there could be another call in that session resetting
the sererside timeout counter.

Clientside cannot know that, unless it pols the server by ajax or alike
to ask the present value of the timeout counter. Under ASP it is not even
available, I suspect the same goes for PHP, but I don't know.

> I would like to, given a timeout such as 30 minutes, have a countdown
> from the onload event. It would then be nice to prompt the user to
> logout or continue the session by sending a message back to the server
> to refresh the session.


You cwertainly can do that, but it does not reflect the session state.

> I say your wrong, because session timeouts ARE being done currently in
> many websites such as banks.


Those sites heavily rely on serverside, I hope.

> ...and I never suggested Google write my
> code, but that Google search find an appropriate example.


You did not suggest anything of the sort, though I might be what was in
your mind. You only said Google had failed you. If that was about
searching and not about the share value, it could also be that your
searching skills were not perfect. How would we know?

> Please troll someplace else if you have nothing constructive to add.


So now you become abusive, thinking this NG is your personal helpdesk and
by asking Qs you have a right to dictate the answers?

My aswer was constructive, showing you you asked the wrong Q an prompting
you to a better one.

A countdown timer in Javascript, you simply could have asked for that,
is a simple affair, can be written within 10 minutes. But you did not ask
for that.

If you stay polite, maybe someone will help you.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
MC
Guest
Posts: n/a
 
      03-22-2008
Sasuke,

Thank you. This should work quite nicely! I will be able to show the user
how much time is left on the page till timeout. I should be able to even
'show' a form saying they are going to time out in soon, and give them the
opportunity to refresh the session with a button there.

Thank you for helping!
MC


 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      03-22-2008
Dr J R Stockton wrote on 22 mrt 2008 in comp.lang.javascript:

>>Session is a serverside concept.
>>Clientside, thee is not such a thing as a session timeout.

>
> A client can count down for a length of time indicated by the server;
> and can occasionally be synchronised with the server's opinion.
>


However, John, the server, under ASP at least,
does not know at the scripting level,
what the countdown status of the session timer is,
so much for the server's opinion.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
Joost Diepenmaat
Guest
Posts: n/a
 
      03-22-2008
"Evertjan." <(E-Mail Removed)> writes:

> However, John, the server, under ASP at least,
> does not know at the scripting level,
> what the countdown status of the session timer is,
> so much for the server's opinion.


That can't be right. There may be no direct way of querying that info,
but one would assume the timeout is configurable (and so, knowable) and
reset at each page request. Which is all you'd need to know for doing
this fairly accurately.

--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
 
Reply With Quote
 
MC
Guest
Posts: n/a
 
      03-23-2008
Joost,

Exactly what I was thinking...given a timeout such as 30 minutes, a client
page onload should be able to approximate the timeout. I have seen several
examples of this on bank sites. It doesn't matter if its ASP, JSP, PHP, or
CF. Just that the client is passed or stored in the page what the timeout
will be.

MC


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a countdown timer for a GUI in blueJ lauraa Software 0 04-18-2010 02:50 PM
Countdown timer for different timezones Dirk Hagemann Python 1 07-06-2006 03:18 PM
Countdown Timer KennethGorelick Python 2 02-19-2006 10:36 PM
JSP countdown timer agold791@hotmail.com Java 4 11-03-2005 02:17 AM
GUI countdown timer in a JApplet? Ryan Stewart Java 2 12-24-2003 07:22 PM



Advertisments