Below is the code Ultradev wrtote for me to login I want to extend this so by writing a cookie the user only has to log in once but i do not seem to be able to write the cookie when a valid user enters. See code in green.
Can anyone tell me why? also how do I get this to work from a checkbox tick and automatically log people past this page
thanks in advance
SDh
MM_LoginAction = Request.ServerVariables("URL"
If Request.QueryString<>"" Then MM_LoginAction = MM_LoginAction + "?" + Request.QueryString
MM_valUsername=CStr(Request.Form("txtUsername")
If MM_valUsername <> "" Then
MM_fldUserAuthorization="access_level"
MM_redirectLoginSuccess="default2.asp"
MM_redirectLoginFailed="unauthorised.asp"
MM_flag="ADODB.Recordset"
set MM_rsUser = Server.CreateObject(MM_flag)
MM_rsUser.ActiveConnection = MM_connweb_STRING
MM_rsUser.Source = "SELECT Login, Password"
If MM_fldUserAuthorization <> "" Then MM_rsUser.Source = MM_rsUser.Source & "," & MM_fldUserAuthorization
MM_rsUser.Source = MM_rsUser.Source & " FROM Users WHERE Login='" & MM_valUsername &"' AND Password='" & CStr(Request.Form("txtpassword") & "'"
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" = MM_valUsername
Response.Buffer=true
Response.Cookies("ID"("Username"=MM_valusername
Response.Cookies("ID"("Password"= MM_rsuser("Password"
If (MM_fldUserAuthorization <> "" Then
Session("MM_UserAuthorization" = CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value)
Else
Session("MM_UserAuthorization" = ""
End If
if CStr(Request.QueryString("accessdenied") <> "" And false Then
MM_redirectLoginSuccess = Request.QueryString("accessdenied"
End If
MM_rsUser.Close
Response.Redirect(MM_redirectLoginSuccess)
End If
MM_rsUser.Close
Response.Redirect(MM_redirectLoginFailed)
End If
Can anyone tell me why? also how do I get this to work from a checkbox tick and automatically log people past this page
thanks in advance
SDh
MM_LoginAction = Request.ServerVariables("URL"
If Request.QueryString<>"" Then MM_LoginAction = MM_LoginAction + "?" + Request.QueryString
MM_valUsername=CStr(Request.Form("txtUsername")
If MM_valUsername <> "" Then
MM_fldUserAuthorization="access_level"
MM_redirectLoginSuccess="default2.asp"
MM_redirectLoginFailed="unauthorised.asp"
MM_flag="ADODB.Recordset"
set MM_rsUser = Server.CreateObject(MM_flag)
MM_rsUser.ActiveConnection = MM_connweb_STRING
MM_rsUser.Source = "SELECT Login, Password"
If MM_fldUserAuthorization <> "" Then MM_rsUser.Source = MM_rsUser.Source & "," & MM_fldUserAuthorization
MM_rsUser.Source = MM_rsUser.Source & " FROM Users WHERE Login='" & MM_valUsername &"' AND Password='" & CStr(Request.Form("txtpassword") & "'"
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" = MM_valUsername
Response.Buffer=true
Response.Cookies("ID"("Username"=MM_valusername
Response.Cookies("ID"("Password"= MM_rsuser("Password"
If (MM_fldUserAuthorization <> "" Then
Session("MM_UserAuthorization" = CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value)
Else
Session("MM_UserAuthorization" = ""
End If
if CStr(Request.QueryString("accessdenied") <> "" And false Then
MM_redirectLoginSuccess = Request.QueryString("accessdenied"
End If
MM_rsUser.Close
Response.Redirect(MM_redirectLoginSuccess)
End If
MM_rsUser.Close
Response.Redirect(MM_redirectLoginFailed)
End If