Micro Focus QTP (UFT) Forums
script for deleting cookies - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Interview Questions (https://www.learnqtp.com/forums/Forum-UFT-QTP-Interview-Questions)
+--- Thread: script for deleting cookies (/Thread-script-for-deleting-cookies)



script for deleting cookies - mrajeshtnl - 02-24-2012

Recently i face this question in an interview, write a script to delete cookies..

help me to know the script..

thanks for every help


RE: script for deleting cookies - Ankesh - 02-24-2012

Hi,
Try the below code.

Code:
Function ClearCookies()
    On Error Resume Next
    Const TEMPORARY_INTERNET_FILES = "&H20&"
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objShell = CreateObject("Shell.Application")
    Set objFolder = objShell.Namespace(TEMPORARY_INTERNET_FILES)
    objFSO.DeleteFile(objFolder.Self.Path & "\*.*")

    sPath = objFSO.GetFolder(objFolder.Self.path) & "\Content.IE5\"
    Set objFolders = objFSO.GetFolder(sPath)
    For Each objFName In objFolders.SubFolders
        WScript.Echo sPath & objFName.Name
        objFSO.DeleteFolder(sPath & objFName.Name)
    Next
    If Err.Number <> 0 Then
       err.Clear
       ClearCookies = 0
     Else
       ClearCookies = 1
      End If    
End Function

Regards,
Ankesh



RE: script for deleting cookies - inborntester - 02-24-2012

https://www.learnqtp.com/how-to-delete-cookies-through-a-script/


RE: script for deleting cookies - ravi.gajul - 02-24-2012

webutil.deletecookies


RE: script for deleting cookies - mrajeshtnl - 02-24-2012

Thank you Ankesh



Thank you Ravi



Thank you, Inborntester, thanks for awareing me to search for my question insted posting a thread, from the next time onwards, before i post a question, i will search in the site...

Thank you every one


RE: script for deleting cookies - rkkumar - 03-06-2012

Code:
webutil.deletecookies
    Set WshShell = CreateObject("WScript.Shell")
    WshShell.run "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351"