views:

29

answers:

1

I am looking for the API calls that would allow loading cookies into IE from say a text file. I believe this should be possible since IE has a import/export facility for cookies, feeds and favorites. When performing this kind of operation besides recreating the cookie txt files, index.dat must be also updated, otherwise the cookies won't work. Thanks!

A: 

To export the cookies from the source browser, use FindFirst/FindNextUrlCacheEntry() and specify COOKIE_CACHE_ENTRY in the INTERNET_CACHE_ENTRY_INFO structure you pass. Once you get the entry, you can persist all the relevant fields in whatever format you want, though the data is not guaranteed to be pure ASCII, so a text file will work as long as you use the proper encodings.

To import cookies from your data file, use SetUrlCacheEntryInfo().

jeffamaphone
In the end it looks like FindFirst/FindNextUrlCacheEntry() is the way to go. To get cookie data one can use InternetGetCookie. However this api call does not retrieve HttpOnly cookies. Alternatively one can open the cookie files and extract relevant data and save it in the format used by InternetGetCookie. To load the cookie back into IE, use InternetSetCookie.