|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I am thinking of implementing a method of checking if users have just closed a browser window, instead of logging out of the site correctly. My thought was to have a Timer function written in Javascript that would write a time to a database every 5 minutes, then if someone closed the browser and then tried to log in again, if the time period between now and the last time that had been written was greater than 5 I could assume that they had incorrectly logged out.
My question is, as I don't know how to write to a database in Javascript, or even if it's possible, is it possible to include VB Script within a Javascript function? Also as I am not too familiar with Javascript, if anyone has any suggestions on what is written below and how to improve it I'm all ears. Here is what I would expect the structure to look like: var gTimer2 = null; var gTimer2Count = 0; function Timer2() { gTimer2Count++; <% strsql = "select * from Register WHERE userid = '" & Useridvariable "';" sqlRecordset.open strsql, cnDB, 1, 3 sqlRecordset("LatestTime") = now() sqlRecordset.update sqlRecordset.close %> } gTimer2 = window.setInterval("Timer2()",300000); Is this at all possible, or can someone perhaps comment on how it might be achieved. I realise, after looking on the net, and through this forum, that people closing the browser window without logging out is not an easy thing to catch, so just thought that this might work in my case. |
|
#2
|
||||
|
||||
|
You cannot update a server side database with client side code.
Can't you do something with cookies? Set one when they login and remove it when the correctly log out? |
|
#3
|
|||
|
|||
|
What about an onclose event which opens a new window, pulls some code from the server which can update your server side database, generates a simple "thanks for using my ace site" message and closes the new window.
might be stopped by pop-up software, but might just be a different direction to view the problem from? HTH Iain |
![]() |
| Viewing: ASP Free Forums > Programming > HTML, JavaScript And CSS Help > Javascript Timer |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|