How to delete cookies
-
- Posts: 49
- Joined: Thu Feb 03, 2011 3:15 pm
How to delete cookies
What is the code to delete cookies from IE and Firefox browsers
Re: How to delete cookies
I don't think this is Ranorex specific, but anyway you can use something similar to the code below. It depends on the OS you are using too, see http://www.deletecookiesnow.com/cookies-location.html for the different locations.
On XP, it would be the following
DeleteFiles("C:\Documents and Settings\" & SystemInformation.UserName & "\Cookies", "*.txt")
Public Sub DeleteFiles(ByVal Path As String, ByVal SearchPattern As String)
Console.WriteLine("DeleteFiles " & Path & " - " & SearchPattern)
Dim Dir As New DirectoryInfo(Path)
For Each File As FileInfo In Dir.GetFiles(SearchPattern)
Console.WriteLine("Deleting the file " & File.Name)
File.Delete()
Next
End Sub
Hope this helps!
On XP, it would be the following
DeleteFiles("C:\Documents and Settings\" & SystemInformation.UserName & "\Cookies", "*.txt")
Public Sub DeleteFiles(ByVal Path As String, ByVal SearchPattern As String)
Console.WriteLine("DeleteFiles " & Path & " - " & SearchPattern)
Dim Dir As New DirectoryInfo(Path)
For Each File As FileInfo In Dir.GetFiles(SearchPattern)
Console.WriteLine("Deleting the file " & File.Name)
File.Delete()
Next
End Sub
Hope this helps!