Hi all, this is my first post so be nice :)
I did similar thing on my website, I have 2 type of users using the same login. I also use a frameset so the code need to be in one of my frame page only. The reason of a frameset is that I have to query only one time to get the user informations instead of everytime a page is loaded. Here is the code I use. P.S. That code is part of the common.asp file starting at line 259. For security purpose my connection string is not included. You will need to create yours. Conn is the ADODB object
'Read in users ID number from the cookie
strLoggedInUserCode = Trim(Mid(Request.Cookies("Forum")("UserID"), 1, 44))
'Make the usercode SQL safe
strLoggedInUserCode = formatSQLInput(strLoggedInUserCode)
'If a cookie exsists on the users system then read in there username from the database
If strLoggedInUserCode <> "" Then
'Intialise the ADO recordset object
Set rsLoggedInUser = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT tblAuthor.Username, tblAuthor.Author_ID, tblAuthor.Active, tblAuthor.Signature, tblAuthor.Author_email, tblAuthor.Status "
strSQL = strSQL & "FROM tblAuthor "
strSQL = strSQL & "WHERE User_code = '" & strLoggedInUserCode & "';"
'Query the database
Set rsLoggedInUser = Conn.Execute(strSQL)
'If the database has returned a record then run next bit
If NOT rsLoggedInUser.EOF Then
'Before getting the users details make sure then are not trying to log in under the guest account
If rsLoggedInUser("Author_ID") <> 2 Then
'Read in the users details from the recordset
strGlobalLoggedInUsername = rsLoggedInUser("Username")
lngLoggedInUserID = CLng(rsLoggedInUser("Author_ID"))
blnActiveMember = CBool(rsLoggedInUser("Active"))
If rsLoggedInUser("Author_Email") <> "" Then blnLoggedInUserEmail = True
If rsLoggedInUser("Signature") <> "" Then blnLoggedInUserSignature = True
intMemberStatus = CInt(rsLoggedInUser("Status"))
'If the members account is not active then set there security level to 0 (Guest)
If blnActiveMember = False Then intMemberStatus = 0
Else
lngLoggedInUserID = 0
End If
'Otherwise the username is not correct or the user has been barred so set there User ID to 0
Else
lngLoggedInUserID = 0
End If
Set rsLoggedInUser = Nothing
'Close the recordset
rsLoggedInUser.Close
Set rsLoggedInUser = Nothing
End If
The strGlobalLoggedInUsername variable hold your user name. Hope this will help you.