I am working on implementing a "presence" feature on a website built on a classic asp (vbscript), SQL Server, javascript, IIS7 stack.
The existing authentication/log in system uses sessions, with a default 20 minute session timeout. The user data is stored in a SQL Server table. A cookie is also set when a user logs in, which enables tracking of registered users even when not logged in.
There is a column in the USERS table which holds the state e.g. "online" or "offline". The following is the logic I've come up with thus far:
Status is set to "online" when:
- user logs in
- a cookie is detected e.g. user returns but doesn't yet log in
Status set to "offline" when:
- user logs out
- user closes browser (use a javascript event to detect)
- user navigates away from the site (not sure yet how best to detect this)
- users session expires (handled in global.asa's Session_OnEnd subroutine)
Questions:
- Am I overlooking anything in the logic presented above?
- What is the best way (within js / classic asp) to detect items 2 and 3 above in the "when to set status to 'offline'" list
Thanks