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: 16045
  • 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

#2 User is offline   gonzalosb 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 170
  • Joined: 11-September 13

Posted 17 June 2014 - 04:49 PM

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.
0

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