How to clean up internet explorer cookies programmatically?
Is there some windows API function to do it?
Actually, I got it!
In Windows API you have a function to create cookies called InternetSetCookie
, and you use it like this:
InternetSetCookie("http://teste.com", NULL, "name = value; expires = Sat,01-Jan-2020 00:00:00 GMT");
But, if you want to delete the cookie instead of creating it, you just have to set the expiration field somewhere in the past, like this:
InternetSetCookie("http://teste.com", NULL, "name = value; expires = Sat,01-Jan-2000 00:00:00 GMT");
More info about it in Managing Cookies.
Couldn't you just search C:\Documents and Settings\user\Local Settings\Temporary Internet Files
for files with 'cookie' in the filename?
Here's the Win32 call to get the folder:
BOOL SHGetSpecialFolderPath(
HWND hwndOwner,
LPTSTR lpszPath,
int nFolder,
BOOL fCreate
);
Pass CSIDL_COOKIES
as the nFolder
argument.
Check this link out A Cleanup API for Windows.
You can delete cached cookies via the FindFirstUrlCacheEntry
,FindNextUrlCacheEntry
and DeleteUrlCacheEntry
functions. You can pass 'cookie:' as the first argument (LPCTSTR lpszUrlSearchPattern
) to FindFirstUrlCacheEntry
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With