Jump to content
mendrofa

delete cookies

Recommended Posts

aleph01

In the search window or in the run command type shell:cookies.  That'll open a window to where your cookies are stored.  Use that path and the filedelete command.


Meds.  They're not just for breakfast anymore. :'(

Share this post


Link to post
Share on other sites
Exit

unfortunately, "shell:cookies" shows not all cookies.

Just type ":cookies" in search field of home drive and you'll see much more cookies.


My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites
genius257
6 hours ago, aleph01 said:

In the search window or in the run command type shell:cookies.  That'll open a window to where your cookies are stored.  Use that path and the filedelete command.

Path may vary from OS version. Use the API designed for this:

#include "WinINet.au3"

$avCacheEntry = _WinINet_FindFirstUrlCacheEntry(1)
If Not @error Then
    $hCacheEntry = $avCacheEntry[0]
    $avCacheEntryInfo = $avCacheEntry[1]

    While Not @error
        _WinINet_DeleteUrlCacheEntry($avCacheEntryInfo[1])
        
        $avCacheEntryInfo = _WinINet_FindNextUrlCacheEntry($hCacheEntry)
    WEnd
    _WinINet_FindCloseUrlCache($hCacheEntry)
EndIf

The WinINet.au3 can be found here: WinINet.au3 (FTP/HTTP/HTTPS/Gopher+)

FYI the script is using a macro, now removed in the WinINetConstants.au3. On line 5 simply replace @AutoItUnicode with 1 like so:

Global Const $AU3_UNICODE = Number($AU3_VERSION[2] & "." & $AU3_VERSION[3]) >= 2.13 Or 1

Note that the _WinINet_DeleteUrlCacheEntry sets @error if the function succeeds instead of expected behavior

Edited by genius257

Share this post


Link to post
Share on other sites
Exit

@genius257   I tried your code, but no full success.

Running IE11 on WIN10
Some cookies were deleted, but not all. All newer cookies were not found e.g. Google.com , Bing.com
A search for ".cookie" on the Home drive C: showed about 150 existing cookies.  I deleted them all.
Furthermore, I deleted cookies in IE11

Then I called 'Google.com' on IE11. After that, there were 4 cookies from Google.
Always searching for '.cookie' on the home drive is no good solution, isn't it?

My goal is to delete those Google cookies. How can I do this with AutoIt?

TIA Exit


 


My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites
Exit

Here a code to display all cookies and to delete selected cookies.

#include <Array.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>

$searchfor = "Google."

Local $aArray = _FileListToArrayRec(@UserProfileDir, "*.cookie", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH)
_ArrayDisplay($aArray, "All cookie data sets")
For $i = 1 To $aArray[0]
    $sFiledata = FileRead($aArray[$i])
    ConsoleWrite($aArray[$i] & @CRLF & $sFiledata & @CRLF & @CRLF)
    If StringInStr($sFiledata, $searchfor) Then
        If MsgBox($MB_YESNO + $MB_ICONQUESTION + $MB_DEFBUTTON2, $searchfor, $aArray[$i] & @CRLF & @CRLF & $sFiledata & @CRLF & @CRLF & "Delete this cookie ?", 0) = $IDYES Then FileRecycle($aArray[$i])
    EndIf
Next

 


My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.