How to delete cookies

Experiences, small talk, and other automation gossip.
Posts: 49
Joined: Thu Feb 03, 2011 3:15 pm

How to delete cookies

Post by bheemuabhigna » Fri Feb 11, 2011 11:21 am

What is the code to delete cookies from IE and Firefox browsers

User avatar
Posts: 238
Joined: Mon May 10, 2010 11:04 am
Location: Dundee, Scotland

Re: How to delete cookies

Post by sdaly » Fri Feb 11, 2011 1:12 pm

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 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)
End Sub

Hope this helps!