Hack Forums
[.NET] Add Cookies to WebBrowsers Control - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Add Cookies to WebBrowsers Control (/showthread.php?tid=5665742)



Add Cookies to WebBrowsers Control - MalwareMop - Jul 9, 2017

Solution found. Thanks to Das, appreciated.


* - Ninja - Jul 9, 2017

Are you sure the cookies are set? And if so, are you sure they are valid?


* - MalwareMop - Jul 9, 2017

(Jul 9, 2017 06:17 PM)Ninja Wrote:  Are you sure the cookies are set? And if so, are you sure they are valid?

So the above code works for you? Of course they are in the container, it's the first thing I checked. They are also totally valid as I use them in other HTTP webrequests without error. Just when I try to set the actual control does it not work.


* - Ninja - Jul 9, 2017

(Jul 9, 2017 06:28 PM)Gᴏᴠᴇʀɴᴍᴇɴᴛ Wrote:  So the above code works for you?

I never said that.

And idk what the problem is then. If the cookies are set then it should work. Maybe it has to do with the URL? Try using only the host for a domain, don't include a path.

So instead of things like:
http://website.com/page
do:
http://website.com/

Hint: https://msdn.microsoft.com/en-us/library/system.uri(v=vs.110).aspx


* - Das Swag - Jul 9, 2017

(Jul 9, 2017 06:28 PM)Gᴏᴠᴇʀɴᴍᴇɴᴛ Wrote:  So the above code works for you?

[Image: ffBwDTe.png]
Looks like it's working fine for me


* - Das Swag - Jul 10, 2017

You can ignore my PM

Change
Code
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    SetWBCookies(wbCaptcha, LoginCookies, "https://www.tinychat.com")
End Sub

To

Code
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    SetWBCookies(wbCaptcha, LoginCookies, "https://tinychat.com")
End Sub

And you should be set.


Your web requests were going to https://tinychat.com/ so your cookies were getting set to the domain of tinychat.com when you tried to login you grabbed cookies from www.tinychat.com which you had no cookies for, so your cookie container was actually empty.
edited