dcsimg
Results 1 to 5 of 5
  1. #1

    Thread Starter
    Hyperactive Member Krass's Avatar
    Join Date
    Aug 2000
    Location
    Montreal
    Posts
    483

    Injecting my httpRequest cookie into webbrowser

    My googling "skills" couldn't help.

    My simple vb6 app is browsing a webpage and uses a login/password to log in. This is done via http-request, and upon completion, I keep the cookie in a string variable. Like this:
    Code:
    strCookie = GetCookies(httpRequest.getAllResponseHeaders)
    strCookie then contains this: (I've kinda formatted it, line feeds and all..)
    Code:
    JSESSIONID=E1949596_some_id_hereA634159E.awolvprodweb01;
    Path=/;
    Secure;
    HttpOnly;
    _rauv_=E1949596_some_string_hereA634159E.awolvprodweb01_;
    Version=1;
    Domain=thehockeypool.com;
    Max-Age=630720000;
    Expires=Thu, 07-Jan-2038 03:19:45 GMT;
    Path="/;
    HttpOnly
    ";Secure;
    
    _rauv_=E1949596_some_string_hereA634159E.awolvprodweb01_;
    Version=1;
    Domain=thehockeypool.com;
    Max-Age=630720000;
    Expires=Thu, 07-Jan-2038 03:19:45 GMT;
    Path="/;
    HttpOnly
    ";Secure;
    
    _rauv_=E1949596_some_string_hereA634159E.awolvprodweb01_;
    Version=1;
    Domain=thehockeypool.com;
    Max-Age=630720000; 
    Expires=Thu, 07-Jan-2038 03:19:45 GMT;
    Path="/;
    HttpOnly;
    ";Secure;
    
    NSC_MWQSPE-VXQ-IUUQT=fffffff_some_longer_string_5e445a4a422141
    ;expires=Fri, 12-Jan-2018 04:19:45 GMT;
    path=/;
    secure;
    httponly;
    Now that my login is done quickly and easily, I'd like to continue using the webbrowser that sits on my form. No need for http requests anymore. To do this I need this cookie to be "injected" (?) into the webbrowser..... Then I'd be on that web page, logged in. I think that can be done, right?

    Some code found on the web made it sound easy:
    WebBrowser1.navigate "http://domain.tld/page.ext/",,,"Cookie: foo=bar; baz=qux;"
    ...so I thought I could try something like:
    WebBrowser1.navigate "http://domain.tld/page.ext/",,,strCookie

    That obviously didn't work. Perhaps does my strCookie needs to be somehow parsed and/or passed differently to the browser.navigate?

    I've seen a lot of vb.net code that all seems to be using a Net.CookieContainer, perhaps a more conveniant way to store cookie data,.. don't know.

    Thanks to anyone with some suggestions to get this working! Cheers!
    Chris

  2. #2

    Thread Starter
    Hyperactive Member Krass's Avatar
    Join Date
    Aug 2000
    Location
    Montreal
    Posts
    483

    Re: Injecting my httpRequest cookie into webbrowser

    Still no reply! I am starting to wonder if I'm asking for something impossible? I did read that the argument 'PostData' of WebBrowser.navigate could be used for that. Perhaps can someone lightens me, regarding this article: (which I don't quite fully understand)
    https://support.microsoft.com/fr-fr/...rowser-control

    I'm still thinking that I may need to format/convert my strCookie information. Also this articles talks about setting the <Headers> (last param of web.navigate).

    A huge THANK YOU to anyone with ideas on how to use my cookie file shown in the my first post ...........
    Chris

  3. #3
    Frenzied Member
    Join Date
    Jun 2015
    Posts
    1,995

    Re: Injecting my httpRequest cookie into webbrowser

    You're a hyperactive member on here, since 2000, but it seems you've missed all the similar posts in the past.
    Basically due to the abuse of such code and forum guidelines, we typically won't get into these types of requests.
    Pretty much we don't discuss most if not all browser automation.

    My only hint - is you could inject some javascript into a browser control that can update your cookie. I don't actually know - your method looks like it should work.
    Imagine what it would be like to set breakpoints in, or step through subclassing code;
    and then being able to hit stop/end/debug or continue, without crashing the IDE.

    VB6.tlb | Bulletproof Subclassing in the IDE (no thunks/assembly/DEP issues)

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    32,188

    Re: Injecting my httpRequest cookie into webbrowser

    It seems to me that it is as likely to fail as to work, ultimately. Cookies get stale. In some cases, they are stale as soon as they are received. Other times they get stale within minutes, hours, or days.

    As a general rule, if you can avoid automating a website, that is by far the best way to go. That's what APIs are for, and most sites that want you to access their stuff have provided APIs that you can use. If there is one, then use that. If this is your own site, then make yourself an API. If there is no API and this isn't your site, then contact the site owners and ask for an API. They must want you to have access to SOMETHING, because they put up a website, so they may well be willing to provide an API for a request. If they don't want you to access that data in an automated way, then that is also their right, and you should respect that, but it's certainly worth asking.
    My usual boring signature: Nothing

  5. #5

    Thread Starter
    Hyperactive Member Krass's Avatar
    Join Date
    Aug 2000
    Location
    Montreal
    Posts
    483

    Re: Injecting my httpRequest cookie into webbrowser

    Okay I see. I thank you guys for replying anyway..... I'll just avoid http requests anyway.
    Chris

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width