Shawn
|
| Posted: 06/05/2002, 7:47 PM |
|
I am using CCS and trying to get the date of when a user was last logged in. Any help is greatly appreciated.
Shawn
|
|
|
 |
wonko
|
| Posted: 06/05/2002, 11:35 PM |
|
first add an new column in the user-table with the type: date
then, when a user login, you can update this value with the actual date or time.
example for an update-statement:
UPDATE USERS
SET LastLoginDate = Date()
WHERE User = 'Username'
AND Passwd = 'UserCredential';
how this will work in CC or in CCS i do not know exactly, but this is the way i do this when i write code with hand
|
|
|
 |
Stuart Sammels
|
| Posted: 06/06/2002, 1:53 AM |
|
I use this to catch last login and IP address - put it in login form - on login event in codecharge.
'->On Login Event Start
'Record the date/time and IP address of user's login
if bPassed > 0 then
UserID = CStr(DLookUp("members", "member_id", "member_login =" & ToSQL(sLogin, "Text") & " and member_password=" & ToSQL(sPassword, "Text")))
cn.execute "UPDATE members SET members.user_last_login = '" &Now()& "', members.user_last_ip='" & Request.ServerVariables("REMOTE_HOST") & "' WHERE member_id=" & UserID & ";"
end if
'<-On Login Event End
Make sure you have the proper fields in the database.
|
|
|
 |
wonko
|
| Posted: 06/06/2002, 2:32 AM |
|
if you want to log the IP of the user, it would be better to use the following way:
<%
strIPAddress = Trim(Request.ServerVariables("REMOTE_ADDR"))
arrBits = Split(strIPAddress,".")
If (UBound(arrBits) <> 3) Then
Response.Write "Fatal Error parsing IP address of client!"
Response.End
Set strIPAdress = Nothing
%>
<%
...
cn.execute "UPDATE members SET members.user_last_login = '" &Now()& "', members.user_last_ip0='" & arrBits(0) & "',
members.user_last_ip1='" & arrBits(1) & "',
members.user_last_ip2='" & arrBits(2) & "',
members.user_last_ip3='" & arrBits(3) & "' WHERE member_id=" & UserID & ";"
...
Set arrBits = Nothing
%>
the reason: if you write the ip-adress into one single field (datetype: "integer" or "text") you need 15 Bytes.
if you do the way explained above, you need 4 fields (user_last_ip0, user_last_ip1, user_last_ip2, user_last_ip3) with the datetype "Byte".
so you only need 4 Bytes.
this will save 11 Bytes per recordset. and the more recordsets you have, the more you will save.
mfg
wonko der verstandige
|
|
|
 |
|