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")
objShell.Sendkeys "%i"
objShell.Sendkeys "{ENTER}"
objShell.Sendkeys "%f"
objShell.Sendkeys "%d"
objShell.Sendkeys "{ENTER}"
objShell.Sendkeys "{ENTER}"
End Function

I was asked to review this code and i was looking at this little girl 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 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
Cookie:Code to delete Those Cookie:Code to delete Those Reviewed by Animesh Chatterjee on October 21, 2009 Rating: 5

No comments:

Powered by Blogger.