This topic is locked

How to autologin passing username and password via URL

9/10/2009 11:55:35 AM
ASPRunnerPro Tips and tricks
admin

It might be handy to make users logon automatically passing username and password via URL i.e. login.asp?username=test&password=test
To make it work use the following code in BeforeProcess event of login page.



strUsername = Request("username")

strPassword = Request("password")
if strUsername<>"" and strPassword<>"" then

strSQL = "select * from LoginTableName where " & CSmartStr(AddFieldWrappers(cUserNameField)) & "=" & CSmartStr(strUsername) _

& " and " & CSmartStr(AddFieldWrappers(cPasswordField)) & "=" & CSmartStr(strPassword)
logged = false

doAssignment rs,db_query(strSQL,conn)

doAssignment data,db_fetch_array(rs)

if bValue(data) then

if IsEqual(data(cUserNameField),sUsername) and IsEqual(data(cPasswordField),sPassword) then

logged = true

end if

end if

if bValue(logged) then

doArrayAssignment Session,"UserID",pUsername

Session("AccessLevel") = ACCESS_LEVEL_USER

end if

asp_header "Location: menu.asp"

response.end

end if


Replace LoginTableName with login table name. Replace menu.asp with URL of the page where you want to send user.
If you use User Group permissions or Advanced security options you might need to add more code from login.asp to this event.

G
gonzalosb 6/17/2014

hi admin,

i try this code but only get the username to be transfer, not the password.

is "www.myweb.com/login.asp?username=test&password=test"; the correct way to do it?

it this work with ASPR 7.2 or need to be modify in some way.

and can you please expand more, if possible, on what else is needed when User Group permissions or Advanced security options are used?
thank you for your help.