0

Recently try to use a webbrowser component. when I click button, it will navigate to facebook.com. after I login on first time and stop the program. and then when I run the program second time I don't need to fill the email and password. why I don't need to fill an email and password textbox ? thanks

Here's the code

Public Class Form1

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    WebBrowser1.Navigate("m.facebook.com")
End Sub

End Class

Note: I will delete this post, because it doesn't help the community. Just my curiosity. Thanks

how do i need to re-type the email password again when 2nd starting the program

chopperfield
  • 559
  • 1
  • 7
  • 25

1 Answers1

0

You have two options:

  1. The first is to save the CookieContainer associated with the WebBrowser to disk and reload it when you restart your program. There is no straightforward way to serialize cookies to disk or other storage method - that is up to you.

  2. Instruct the WebBrowser object to make use of the user's Windows profile Internet Explorer cookie collection which is shared with Internet Explorer and other programs that also opt-in to sharing state (I do not know if this also applies to the Edge browser, I suspect it does not). See here for instructions on how to do this: Use cookies from CookieContainer in WebBrowser

Dai
  • 141,631
  • 28
  • 261
  • 374
  • Why was this downvoted? I found this quite interesting and informational. Didn't know you could manage/handle the `WebBrowser`'s cookies this way. – Visual Vincent Aug 15 '17 at 09:01