By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,017 Members | 1,169 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,017 IT Pros & Developers. It's quick & easy.

Page Session Countdown Timer

P: n/a
MC
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
Mar 22 '08 #1
Share this Question
Share on Google+
9 Replies


P: n/a
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)
Mar 22 '08 #2

P: n/a
MC
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." <ex**************@interxnl.netwrote in message
news:Xn********************@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)

Mar 22 '08 #3

P: n/a
MC wrote on 22 mrt 2008 in comp.lang.javascript:
"Evertjan." <ex**************@interxnl.netwrote in message
news:Xn********************@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)
Mar 22 '08 #4

P: n/a
MC
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
Mar 22 '08 #5

P: n/a
In comp.lang.javascript message <Xn********************@194.109.133.242>
, Sat, 22 Mar 2008 16:09:49, Evertjan. <ex**************@interxnl.net>
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.
Mar 22 '08 #6

P: n/a
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)
Mar 22 '08 #7

P: n/a
On Mar 23, 4:05 am, "MC" <mica[removethis]@aisus.comwrote:
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
Glad I was able to help. Hope it all works out well for you. :-)
Mar 23 '08 #8

P: n/a
"Evertjan." <ex**************@interxnl.netwrites:
Not fairly at all.

If the user does alt-N and has two duplicate pages, and clicks to another
site page from the second page 15 minutes later, the first page will show
the session is gone, while the session lives on happily [though not ever
after], and the session can be used from the page with the counter that
tells you it cannot.
Yeah that's true. There are ways of working around this problem, of
course. Provided you've got enough control of the session mechanism at
the server side you could just do a periodic Ajax request to check the
session status.

I still don't know what you mean about the *server* scripts not knowing
what the session timer is. Sounds like a really strange restriction to
me.

--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
Mar 23 '08 #9

P: n/a
Joost Diepenmaat wrote on 23 mrt 2008 in comp.lang.javascript:
"Evertjan." <ex**************@interxnl.netwrites:
>Not fairly at all.

If the user does alt-N and has two duplicate pages, and clicks to
another site page from the second page 15 minutes later, the first
page will show the session is gone, while the session lives on
happily [though not ever after], and the session can be used from the
page with the counter that tells you it cannot.

Yeah that's true. There are ways of working around this problem, of
course. Provided you've got enough control of the session mechanism at
the server side you could just do a periodic Ajax request to check the
session status.

I still don't know what you mean about the *server* scripts not
knowing what the session timer is. Sounds like a really strange
restriction to me.
Ours is not to ask the why of the language/platform at implementation
time,
just to implement it.

ASP cannot read the actual state of the session timeout counter.
PSP probably has the same restriction.

The only time that you know it's state is at the reset moment.

You could test by Ajax if the session is still active,
but that would be done "destructively",
as the counter is reset by the test.

Kind of a quantum measurement dilemma, isn't it?
Provided you've got enough control of the session mechanism
You could forego the server internal session mechanism,
[which depends on a session cookie, btw],
and build your own session with a database.
Then you can read the last session reset time from that database.

That probably is the way some banks do their work, having an session-id
in the querystring, and no cookies necessary for that.

The above shows a timeout timer is not even necessary, only a comparison
of 'now' to the last resettime at every new html request [and some sort
of database garbage collection sql execution now and then].
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mar 23 '08 #10

This discussion thread is closed

Replies have been disabled for this discussion.