B
BobRoyAce
I have a form that cycles through a bunch of websites, some of them
multiple times in a row. For each one, it opens up a second form, with
a WebBrowser control on it, and navigates to the website, and
automates loggin in, navigating around, etc. This works just great.
However, for one of the websites, it would appear that some sort of
"session state" is being remembered as when I go to login as another
person, to this same site, I end up at a page that corresponds with
the first person I logged in as.
NOTE 1: I close the form with the WebBrowser control on it each time.
NOTE 2: It doesn't always happen (i.e. inconsistent).
NOTE 3: This error does not seem to happen if I do the same navigation
manually, using IE browser outside of my application, closing the
browser each time.
So, I guess that my question is "How do I clear the 'session state' so
that next time the form is opened, etc., it is not present to goof up
the next login?"
I tried the following code, that I partly got from
http://stackoverflow.com/questions/434469/how-to-clear-system-windows-forms-webbrowser-session-data,
which did not work:
WebBrowser1.Navigate("javascript:void((function(){var
a,b,c,e,f;f=0;a=document.cookie.split('; ');for(e=0;e<a.length&&a[e];e+
+){f++;for(b='.'+location.host;b;b=b.replace(/^(?:%5C.|[^%5C.]+)/,''))
{for(c=location.pathname;c;c=c.replace(/.$/,'')){document.cookie=(a[e]
+'; domain='+b+'; path='+c+'; expires='+new Date((new Date()).getTime
()-1e11).toGMTString());}}}})())")
Any other ideas why I might be having the problem, and how I can fix
it?
multiple times in a row. For each one, it opens up a second form, with
a WebBrowser control on it, and navigates to the website, and
automates loggin in, navigating around, etc. This works just great.
However, for one of the websites, it would appear that some sort of
"session state" is being remembered as when I go to login as another
person, to this same site, I end up at a page that corresponds with
the first person I logged in as.
NOTE 1: I close the form with the WebBrowser control on it each time.
NOTE 2: It doesn't always happen (i.e. inconsistent).
NOTE 3: This error does not seem to happen if I do the same navigation
manually, using IE browser outside of my application, closing the
browser each time.
So, I guess that my question is "How do I clear the 'session state' so
that next time the form is opened, etc., it is not present to goof up
the next login?"
I tried the following code, that I partly got from
http://stackoverflow.com/questions/434469/how-to-clear-system-windows-forms-webbrowser-session-data,
which did not work:
WebBrowser1.Navigate("javascript:void((function(){var
a,b,c,e,f;f=0;a=document.cookie.split('; ');for(e=0;e<a.length&&a[e];e+
+){f++;for(b='.'+location.host;b;b=b.replace(/^(?:%5C.|[^%5C.]+)/,''))
{for(c=location.pathname;c;c=c.replace(/.$/,'')){document.cookie=(a[e]
+'; domain='+b+'; path='+c+'; expires='+new Date((new Date()).getTime
()-1e11).toGMTString());}}}})())")
Any other ideas why I might be having the problem, and how I can fix
it?