[RESOLVED] [2.0] How can I clear cookies and Cache the webbrowser?
I made a simple browser for my wifes class that can only go to one url but it seems to be remembering the last studient who logged on to the website.
i wanted to add something on close or load that would wipe out any cookies or cached sites.
I've been looking around but it looks like everything is geared to wiping out cache files for IE6 or other localy loaded browsers and not just this one instance.
Re: [2.0] How can I clear cookies and Cache the webbrowser?
I assume you used the web browser that 'comes with' Visual Studio, which is in fact a local instance of IE. You can then use Environment.GetFolderPath(Environment.SpecialFolder.Cookies), which you should then scan through for cookies whose names contain the top level domain name of your wife's website. Once you find those, delete it.
Do this in the application's close event.
Of course it'll be more useful if you could find some sort of a setting for that browser which cleared cookies upon unloading, but the method I've mentioned above should be good enough for you.
Re: [RESOLVED] [2.0] How can I clear cookies and Cache the webbrowser?
can anybody elaborate on this please?
How do I scan through the cookies? And then how do I delete them?
Re: [RESOLVED] [2.0] How can I clear cookies and Cache the webbrowser?
You would use the code mendhak provided to get the folder where the cookie files are stored. You'd then have to loop through each file in that folder, for each file (cookie) you'd do some check (such as seeing if it's for the relevent site in the above case), and delete it if appropriate.
Re: [RESOLVED] [2.0] How can I clear cookies and Cache the webbrowser?
i'm getting an error, that I cant access the cookie folder.
Re: [RESOLVED] [2.0] How can I clear cookies and Cache the webbrowser?
Hey,
Can you post the code that you are using, so that we can verify that you are using it correctly?
Also, which OS are you using?
Gary
Re: [RESOLVED] [2.0] How can I clear cookies and Cache the webbrowser?
I was using mendhak's code.
I'm on vs2008express, windows 7
Re: [RESOLVED] [2.0] How can I clear cookies and Cache the webbrowser?
Does mendhak's code get the correct folder?
Re: [RESOLVED] [2.0] How can I clear cookies and Cache the webbrowser?
I'm using this now:
Code:
Function DeleteCookies(ByVal wb As WebBrowser)
wb.Document.Cookie.Remove(0, (wb.Document.Cookie.Count - 1))
Delay(1)
Return False
End Function
I think its working.
Re: [RESOLVED] [2.0] How can I clear cookies and Cache the webbrowser?
Hey,
Why are you using the Delay? I don't see why that would be needed in this case?
Gary
Re: [RESOLVED] [2.0] How can I clear cookies and Cache the webbrowser?
well idk, I dont want the code to proceed until the cookies are deleted, but maybe thats not the way you do it, just a try.
Re: [RESOLVED] [2.0] How can I clear cookies and Cache the webbrowser?
Hey,
Calling Remove is a simple synchronous method, so processing will not continue until that method completes executing, so in this case, the Delay is definitely not needed.
Gary
Re: [RESOLVED] [2.0] How can I clear cookies and Cache the webbrowser?
Re: [RESOLVED] [2.0] How can I clear cookies and Cache the webbrowser?
how would i do this in vb 6?
Re: [RESOLVED] [2.0] How can I clear cookies and Cache the webbrowser?
Hey,
If you have a VB6 question, you should post it in the VB 6 Forum.
Gary