Forums: How to autologin passing username and password via URL - Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How to autologin passing username and password via URL

#1 User is offline   admin 

  • Administrator
  • PipPipPip
  • Group: Admin
  • Posts: 8453
  • Joined: 03-February 03

Posted 10 September 2009 - 03:55 PM

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.


Quote

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.
Best regards,
Sergey Kornilov
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users