vb.net - WebBrowser control and cookies -
i have problem webbrowser control , cookies.
first of happens when 1 navigates in normal web browser (ie9 in case):
1.1. open web page http://www.gmail.com.
i enter username / password,
leave checkbox "stay signed in" unchecked , click "sign in",
ie9 opens gmail page mails listed. ok.
1.2. @ top of gmail page there lot of links "calendar", "documents", etc.
when click "documents" link, documents page opened in separate tab in ie9. no additional login information name / psw asked. fine too.
now, happens when repeat in webbrowser control (i have created simple vb.net application single webbrowser control in it).
2.1. in form load event following code executed:
private sub myform_load(sender system.object, e system.eventargs)
me.mywebbrowser.navigate("http://www.gmail.com")
end sub
2.2. enter gmail login information (name , psw) in webbrowser control,
2.3. when click "documents" link, new instance of ie9 opened,
2.4. instead of showing list of documents, google asks me login again in ie9 window. why? why have enter credentials again?
i think there wrong cookies , not set correctly in step 2.2. have ideas wrong , must done cookies set correctly?
thanks in advance,
sal
additional info:
i have webbrowser newwindow event function implemented as:
private sub mywebbrowser_newwindow(sender system.object, e system.componentmodel.canceleventargs) handles mywebbrowser.newwindow dim cookiesarr string() = mywebbrowser.document.cookie.split(";") each cookie in cookiesarr dim idx long = cookie.indexof("=") if idx <> -1 dim cookiename string = cookie.substring(0, idx).trim dim cookievalue string = cookie.substring(idx + 1).trim internetsetcookie("http://www.google.com", nothing, cookiename + " = " + cookievalue + "; expires = sat,05-jan-2013 00:00:00 gmt") end if next end sub
i believe internetsetcookie() method should store cookies permanently in in "c:\users\administrator\appdata\roaming\microsoft\windows\cookies" directory reuse when google page, requiring authorization, opened.
that because web browser control opening link in separate ie9 window, right? if open or have opened in web browser control window in winforms program, or in same window clicked link, should work properly.
they using in session cookies (in memory) hold login information, not sort written hard drive, why when run process, information (in memory session cookies) not present or propagated new process.
so, intercept link clicking , have open in wb window of choice, need intercept newwindow event, cancel navigation , renavigate using .navigate wb of choice, if need let me know there plenty online.
also, keep in mind web browser control uses ie7 default, though have ie9 installed, can changed via registry.
Comments
Post a Comment