I have a web browser named Webbrowser1 and I wish to have it clear cookies when I click a button. Anyone know how?
Printable View
I have a web browser named Webbrowser1 and I wish to have it clear cookies when I click a button. Anyone know how?
When you create a WebBrowser using the WebBrowser component, you're not actually creating a WebBrowser. You're just adding your own GUI to a strip downed version of IE.
That being said, the WebBrowser component inherits its cache, cookies, and other temporary file locations from IE's locations.
Below is a full list of the codes I use for deleting cache, cookies, history, forms data etc. Just paste the one you want into your buttons click event.
Hope this helps.Code:'Temporary Internet Files
System.Diagnostics.Process.Start("rundll32.exe", "InetCpl.cpl,ClearMyTracksByProcess 8")
'Cookies
System.Diagnostics.Process.Start("rundll32.exe", "InetCpl.cpl,ClearMyTracksByProcess 2")
'History
System.Diagnostics.Process.Start("rundll32.exe", "InetCpl.cpl,ClearMyTracksByProcess 1")
Form(Data)
System.Diagnostics.Process.Start("rundll32.exe", "InetCpl.cpl,ClearMyTracksByProcess 16")
Passwords
System.Diagnostics.Process.Start("rundll32.exe", "InetCpl.cpl,ClearMyTracksByProcess 32")
Delete(All)
System.Diagnostics.Process.Start("rundll32.exe", "InetCpl.cpl,ClearMyTracksByProcess 255")
'Delete All – Also delete files and settings stored by add-ons
System.Diagnostics.Process.Start("rundll32.exe", "InetCpl.cpl,ClearMyTracksByProcess 4351")
Launching an external executable to clear these settings provides unnecessary overhead.
These paths are built into the framework. Their located within the System.IO namespace, within [/b]Environment[/b], I believe.
These paths are indeed built into the Environment namespace. I did some research for deleting cookies etc when I was creating my own web browser application and all of the code I could find to do what I wanted involved multiple lines of code, some of which were quite large. Not sure how Internet Explorer does this, code wise, but the dialogues that appear when these processes are run appear exactly the same as the Internet Explorer ones.