Due to several related questions recently, here is sample implementation based on BookStore example with MS Access:
1. Create the Store solution/example:
http://docs.codecharge.com/studio/html/ProgrammingTechn...SSolutions.html
2. Modify the "Intranet" database example provided with CCS and used in the example, by adding the following fields to the "users" table:
is_online (Yes/No field in MS Access, Boolean otherwise)
date_login (Date/Time field)
3. Open the Login page and navigate to the "DoLogin" button where you will find "Login" action assigned to the "On Click" event of the button. Add the following custom code to the same "On Click" event (you will have both "Login" action and Custom Code assigned to the same event):
Dim Connection
Set Connection = New clsDBinternet
Connection.Open
If Login_DoLogin_OnClick = True And CCGetUserID<>"" Then Connection.Execute("UPDATE users SET is_online=True, date_login=#" & Now() & "# WHERE user_id=" & CCGetUserID)
Connection.Close
Set Connection = Nothing
This is all that is needed to track user logins.
To add tracking of user logouts:
4. Open the Login page and double-click on the "Logout" action assigned to the "After Initialize" event of the page. Once in the Code mode, replace the code that you find there with this version:
If NOT IsEmpty(CCGetParam("Logout", Empty)) Then
Set Connection = New clsDBinternet
Connection.Open
Connection.Execute("UPDATE users SET is_online=False WHERE user_id=" & CCGetUserID)
Connection.Close
Set Connection = Nothing
CCLogoutUser
End If
Note: the Logout is performed by directing users to the Login page via a URL containing "Logout=something". For example:
http://localhost/BookStore/login.asp?Logout=1