Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript that compares and countsdown time

Status
Not open for further replies.

axsom1

Technical User
Feb 27, 2001
67
US
Here is what Im trying to accomplish. A user logs into our webpage and based on their login will be granted 30 minutes or 60 minutes of web time. I would like to be able to show on the screen the time they have left in a little countdown. I currently capture their login time and would also like to reference that so they cant hit the refresh button and get extra time. Is there any way to get this done in javascript?

Thanks,
John Axsom
 

i would use server side scripting to 'capture' the login time and then save that to a file specific to that user. the first time they login, the script checks to see if the login_time file exists. if not, then one is created. write a javascript that *reads* this file and compares to the current time. once that time passes the limit, the file is deleted and the session ends.

this way, once the user logs in, a new file is created and cannot modified. if the user refreshes the browser, the file is server side and will continue to be read...once it's deleted, the user must start the process over again.

there's more to the process, but it's an idea.

does that help?

- g
 
Yeah this is kind of the same idea I have been playing with. Right now I capture their login time as a session variable and then add what ever minutes that are defined in the database for that user and make that the expired time.

My javascript experience is literally cut and paste, so I have no idea how to even get started with writing a script to constantly check the current time against the logged in time. Is there anyway to have javascript check the server time rather than the client time?

Ultimately what I think I need is someway to display the current clock/time that I am referencing and once that reaches the expired time to redirect the user to the login page. Any ideas??

TIA,
John Axsom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top