Real Software Forums

HTTPSocket WebSite Login
Page 1 of 1

Author:  sinner [ Wed Jul 06, 2011 9:47 am ]
Post subject:  HTTPSocket WebSite Login

Hello i was wondering i have a vary simple code in VB6 that logs into a website. I tryed the same in RB but it does not log into the webpage. Am i doing something wrong here?

Private Sub Command1_Click()
WebBrowser1.Document.All("login_email").Value = Email.Text
WebBrowser1.Document.All("login_pass").Value = Password.Text
End Sub

Private Sub Form_Load()
WebBrowser1.Silent = True
WebBrowser1.Navigate ("")
End Sub


Dim form As Dictionary
Dim Cookies , Data As String
Dim i As Integer
form = New Dictionary

form.value("login_pass") = Password.Text

HTTPSocket1.SetFormData( form )
HTTPSocket1.Post( "" )

For i = 0 To HTTPSocket1.pageHeaders.nameCount("set-cookie")-1
Cookies = Cookies + HTTPSocket1.PageHeaders.Value( i ) + "; "

HTTPSocket1.SetRequestHeader( "Cookie", Cookies )

Author:  jlawrence [ Wed Jul 06, 2011 12:30 pm ]
Post subject:  Re: HTTPSocket WebSite Login

are you getting an error of some kind? I always recommend firing up wireshark and see what's going on behind the scenes in cases like this. Maybe an encoding problem or a hidden field that needs to be set.

it is standard http authentication? or a form on a page?
for standard http authentication see this discussion

otherwise for a form, your procedure seems to be correct provided you are returning all the necessary fields/cookies that the site is expecting.

one thing I do notice though that might be causing a problem, you should capture your pageheaders in the HeadersReceived event. The way you have it coded, it just flies through the "" and continues before the page is even delivered, so it probably is skipping right over your for-loop. Remember that httpsockets are asynchronous so you have to wait for results before you proceed.
Good luck

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group