Forums
This topic is locked
Passing a session variable from the Login
Posted 28 Aug 2009 18:29:57
1
has voted
28 Aug 2009 18:29:57 greg dillon posted:
Hi All,Im pulling my hair out here. I need to get this up and running before i become another recession statistic.
Basically im using the login provided by DW and its working fine. But i need to call a session variable i.e. the dw script looks up username & password in the tblLogin. I need to create a variable for the corresponding entryid (which is a unique number). any have any help. It would really be appreciated.
*************
<%
' *** 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("Username")
If MM_valUsername <> "" Then
Dim MM_fldUserAuthorization
Dim MM_redirectLoginSuccess
Dim MM_redirectLoginFailed
Dim MM_loginSQL
Dim MM_rsUser
Dim MM_rsUser_cmd
Dim MM_IELoginID
MM_fldUserAuthorization = "Companyid"
MM_redirectLoginSuccess = "home.asp"
MM_redirectLoginFailed = "loginbad.asp"
MM_rsUser = Session("IELoginID"
Session("IELoginID" = (rsUser.Fields.Item("entryid".Value)
MM_loginSQL = "SELECT usrname, pword,entryid"
[?]If MM_fldUserAuthorization <> "" Then MM_loginSQL = MM_loginSQL & "," & MM_fldUserAuthorization
MM_loginSQL = MM_loginSQL & " FROM dbo.tblIELogin WHERE usrname = ? AND pword = ?"
Set MM_rsUser_cmd = Server.CreateObject ("ADODB.Command"
MM_rsUser_cmd.ActiveConnection = MM_123_STRING
MM_rsUser_cmd.CommandText = MM_loginSQL
MM_rsUser_cmd.Parameters.Append MM_rsUser_cmd.CreateParameter("param1", 200, 1, 50, MM_valUsername) ' adVarChar
MM_rsUser_cmd.Parameters.Append MM_rsUser_cmd.CreateParameter("param2", 200, 1, 50, Request.Form("Password") ' adVarChar
MM_rsUser_cmd.Prepared = true
Set MM_rsUser = MM_rsUser_cmd.Execute
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
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 true 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
%>
Replies
Replied 16 Sep 2009 13:09:08
16 Sep 2009 13:09:08 Patrick Julicher replied:
Hi Greg,
I'm not quit sure about the code you added, but when using the standard DW Login behavior, a Session Variable named MM_Username is automatically created. If you want to get the details from the user that logged in, just crete a recordset and have it filter the data from the login table to correspond with this session variable!
Hope this works for you!
Kind regards, Patrick
I'm not quit sure about the code you added, but when using the standard DW Login behavior, a Session Variable named MM_Username is automatically created. If you want to get the details from the user that logged in, just crete a recordset and have it filter the data from the login table to correspond with this session variable!
Hope this works for you!
Kind regards, Patrick