Forums
This topic is locked
Update login date
23 Jun 2006 13:26:39 YC ong posted:
I encountered update login date problem. I can update the login date at 1st time login only. Then after that, i can't update the login date into sql already. I can only update the login date again after close the internet explorer and login again.I am fresh in ASP VB script. I wrote some update code in the Log In User function as below:
' *** Validate request to log in to this site.
MM_LoginAction = Request.ServerVariables("URL"
If Request.QueryString<>"" Then MM_LoginAction = MM_LoginAction + "?" + Server.HTMLEncode(Request.QueryString)
MM_valUsername=CStr(Request.Form("txtUserName"
If MM_valUsername <> "" Then
MM_fldUserAuthorization="AccessLevel"
MM_redirectLoginSuccess="Home.asp"
MM_redirectLoginFailed="loginUnsuccessful.asp"
MM_flag="ADODB.Recordset"
set MM_rsUser = Server.CreateObject(MM_flag)
MM_rsUser.ActiveConnection = MM_InternalWeb_STRING
MM_rsUser.Source = "SELECT UserName, Password"
If MM_fldUserAuthorization <> "" Then MM_rsUser.Source = MM_rsUser.Source & "," & MM_fldUserAuthorization
MM_rsUser.Source = MM_rsUser.Source & " FROM dbo.UserDetail WHERE UserName='" & Replace(MM_valUsername,"'","''"
MM_rsUser.CursorType = 0
MM_rsUser.CursorLocation = 2
MM_rsUser.LockType = 3
MM_rsUser.Open
If Not MM_rsUser.EOF Or Not MM_rsUser.BOF Then
' username and password match - this is a valid user
Session("MM_Username"
strSQL="UPDATE UserDetail set loginDt=getdate() where UserName='" & Session("MM_Username"
set Update = Server.CreateObject("ADODB.Command"
Update.ActiveConnection = MM_InternalWeb_STRING
Update.CommandText=strSQL
Update.Execute
Update.ActiveConnection.Close
set Update=nothing
Response.Redirect(MM_redirectLoginSuccess)
If (MM_fldUserAuthorization <> ""
Session("MM_UserAuthorization"
Else
Session("MM_UserAuthorization"
End If
if CStr(Request.QueryString("accessdenied"
MM_redirectLoginSuccess = Request.QueryString("accessdenied"
End If
End If
MM_rsUser.Close
set MM_rsUser=nothing
Response.Redirect(MM_redirectLoginFailed)
End If
%>
Can someone help? Thanks in advance.