• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Countdown Timer on every navigated webpages

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I would like to have a countdown timer (example: 60min, I use MS Visual Studio C# or javascript) for my websites so that the timer can countdown as I navigated from one webpage to another webpage until I click on the Logout button or the timer will auto logout the user once the 60min countdown is reached. I was not able to get the required timer codes from Google search because either the timer cannot be started or activate upon successfully login or  the timer will always restarted/reset by itself on the redirected webpage which mean it is not able to continue the countdown process from one webpage to another webpage. Thanks.
 
Saloon Keeper
Posts: 12147
258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to CodeRanch!

You should store the time the user last logged in in their session. You can calculate the amount of time they've been logged in by subtracting the current time from the login time.

When the remaining time is zero and the user GET requests a page that requires authentication, you forward them to a page notifying them their session has timed out and that they need to log in again. Don't do this for requests other than GET, because a user might want to save changes they've made before the time ran out.

You can also introduce a live timer in JavaScript on the web page that counts down from the remaining time to zero, but you shouldn't let it automatically redirect when it reaches zero, because once again, the user might lose information they've typed into forms etc.
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic