Page 1 of 1

How to delete cookies

Posted: Fri Feb 11, 2011 11:21 am
by bheemuabhigna
What is the code to delete cookies from IE and Firefox browsers

Re: How to delete cookies

Posted: Fri Feb 11, 2011 1:12 pm
by sdaly
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!