Header Ads

Cookie:Code to delete Those

Yesterday... while i was about to return to my home,By chance i saw one of my mate is trying to code on Cookie. She has written a very beautiful code to clear all cookies...

Let me share the code:
Call ClearCookies


Function ClearCookies()
SystemUtil.Run "Control.exe","inetcpl.cpl"
Set objShell = CreateObject("Wscript.Shell")
Do Until done = True
done = objShell.AppActivate("Internet Properties")
Wait(1)
Loop
objShell.Sendkeys "%i"
Wait(1)
objShell.Sendkeys "{ENTER}"
Wait(1)
objShell.Sendkeys "%f"
Wait(1)
objShell.Sendkeys "%d"
Wait(1)
objShell.Sendkeys "{ENTER}"
Wait(4)
objShell.Sendkeys "{ENTER}"
End Function

I was asked to review this code and i was looking at this little girl ....how nice the code is.....with all her permission i have taken her code and modified and published here.

Well , Even though this code is nice but while doing automation , we need to take care about the execution time as well.If we are executing this many lines ....it is going to take a lot of time.
So we were looking for a better code replacement....

The QTP help was not showing anything regarding these but while googling we got an code...
We can use WebUtil.(Method)

webutil.DeleteCookie--Can delete a single doman's Cookie
webutil.DeleteCookies-Can delete multiple domain's Cookies

But while googling we saw there are few problems on IE-6,IE-7 for these one liner code.

Let me find out the codes , commands to solve these problem.I will be publishing soon.
Till then use one of the method to delete cookies
Powered by Blogger.