PC Review


Reply
Thread Tools Rating: Thread Rating: 2 votes, 3.00 average.

Clearing "session state" of WebBrowser control

 
 
BobRoyAce
Guest
Posts: n/a
 
      27th Aug 2009
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/4...r-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?
 
Reply With Quote
 
 
 
 
John Bundy
Guest
Posts: n/a
 
      31st Aug 2009
This could be caused by a few things, not only are their cookies, but I have
run into sites that actually store a file out in a temp directory that has to
be erased. Depending on the site, what works for me the most often is adding
a ? and a digit to the end of the URL. This is typically passed straight
through as it usually contains parameters for a page or query, and it does
seem to open a new page every time. Cant guarantee it will work for you in
this situation, but it has worked for me everytime i have used it. I just add
? and i have a function that apends a random 7 digit number onto the end.
--
-John http://www.jmbundy.blogspot.com/
Please rate when your question is answered to help us and others know what
is helpful.


"BobRoyAce" wrote:

> 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/4...r-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?
>

 
Reply With Quote
 
BobRoyAce
Guest
Posts: n/a
 
      7th Sep 2009
Thanks for the idea.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Session state can only be used when enableSessionState is set to true" Error Paul Microsoft ASP .NET 3 11th Feb 2007 11:20 PM
HttpError "Session state has created a session id..." PL Microsoft ASP .NET 2 10th Nov 2005 04:25 PM
Is "InProc" suitable for production Session State? James Hunter Ross Microsoft ASP .NET 13 18th Oct 2005 01:49 AM
Session State - What does it take to establish one single ASP.NET session per "browser session" Jeff Smythe Microsoft ASP .NET 3 2nd Jan 2004 04:10 AM
webbrowser control loses session state Paul Boyes Microsoft C# .NET 1 25th Dec 2003 05:34 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:09 PM.