Results 1 to 6 of 6

Thread: WebBrowser control and cookies [RESOLVED]

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2000
    Location
    NJ, USA
    Posts
    326

    Resolved WebBrowser control and cookies [RESOLVED]

    I have an app that contains a WebBrowser control. The app navigates the WebBrowser to a login page, fills out the login form and submits it. That works fine.

    The problem is, is that once I'm logged into the website in order to use a certain feature of it, it launches a second browser window which is, of course, Internet Explorer. I don't mind that it launches a second independent browser but I don't believe the cookies are moving to the new browser window and I'm prompted to log back in all over again. This happens on a couple of different sites.

    Anyone have any ideas?
    Last edited by Chris H; Nov 8th, 2004 at 11:58 AM.
    VB.NET 2005 Express with .Net 2.0
    C# 2010 .Net 4.0

  2. #2
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871
    Hi,

    I believe there was a thread like this one a couple of weeks back. If I recall well, he tried a lot but didn't solve the problem. The easiest solution I can come up with is not letting the Web Browser control open up a new window, but having the new URL launch in the control itself. Would that work for you?
    Author for Visual Basic Web Magazine

    My articles on the Web Browser Control:
    Using the Web Browser Control & Using the DHTML Document Object Model

    The examples referenced in the articles can be found here:

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2000
    Location
    NJ, USA
    Posts
    326
    Originally posted by TheVader
    Hi,

    I believe there was a thread like this one a couple of weeks back. If I recall well, he tried a lot but didn't solve the problem. The easiest solution I can come up with is not letting the Web Browser control open up a new window, but having the new URL launch in the control itself. Would that work for you?
    Hmm... that might work... do you think it would work by launching it into my own Form with another browser instead?
    VB.NET 2005 Express with .Net 2.0
    C# 2010 .Net 4.0

  4. #4
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871
    Originally posted by Chris H
    Hmm... that might work... do you think it would work by launching it into my own Form with another browser instead?
    Hmm, I doubt it; though it could work. This code opens the url in an instance of frmBrowser. Try it out and let me know.
    VB Code:
    1. Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
    2. Dim frm As frmBrowser
    3. Set frm = New frmBrowser
    4. Load frm
    5. Set ppDisp = frm.WebBrowser1
    6. frm.Show
    7. Set frm = Nothing
    8. End Sub
    Author for Visual Basic Web Magazine

    My articles on the Web Browser Control:
    Using the Web Browser Control & Using the DHTML Document Object Model

    The examples referenced in the articles can be found here:

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2000
    Location
    NJ, USA
    Posts
    326
    The new form and browser launch okay, but the browser doesn't seem to be navigating to the page specified by the link. I just get a blank browser window. Is there other code to make the new browser window go where it is supposed to?

    EDIT: I must say though, that if I manually navigate the browser to the link by doing frm.WebBrowser1.Navigate "http://www.secure.com" that the "cookies" do appear to be travelling to the new browser window properly. If I could have it navigate there automatically that'd be great.
    Last edited by Chris H; Nov 8th, 2004 at 11:24 AM.
    VB.NET 2005 Express with .Net 2.0
    C# 2010 .Net 4.0

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2000
    Location
    NJ, USA
    Posts
    326
    Okay I think I got it. I changed :

    Set ppDisp = frm.WebBrowser1

    to

    Set ppDisp = frm.WebBrowser1.object

    and that did the trick.

    Thanks for your help. I should be able to work with this just fine.
    VB.NET 2005 Express with .Net 2.0
    C# 2010 .Net 4.0

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width