Comments on the code for importing ie cookies from Firefox

Source: Internet
Author: User

When Firefox is installed, it will ask you if you want to import data from other browsers, such as IE cookies and history. The imported code is in

Browser/components/migration/src/nsieprofilemigrator. cpp

The cookie import code is:

/* Fetch and translate the current user's cookies. <br/> return true if successful. */<br/> nsresult <br/> nsieprofilemigrator: copycookies (prbool areplace) <br/> {<br/> // ie cookies are stored in files named <username> @domain?n=.txt <br/> // (in <username>'s cookies folder. isn' t the naming redundant ?) <Br/> nsresult Rv = ns_ OK; <br/>... </P> <p> return RV; <br/>}< br/>

 

This part of the code is very long and I will not completely paste it here. In general, we just want to find the path where Ie saves the cookie file. If Vista enables UAC, the path is different. We also need to make judgments separately and then read the files one by one. This implementation is not perfect. Win32 already provides a ready-made API:

Handle findfirsturlcacheentry (<br/> _ in lpctstr lpszurlsearchpattern, <br/> _ out signature, <br/> _ inout lpdword lpcbcacheentryinfo <br/> ); <br/>

If the first parameter is set to "Cookie:", you can enumerate all the stored cookies. this API has been provided since Windows 2000, and Windows 2000 is also the lowest version of Windows supported by Firefox, so there is no compatibility problem.
Using a good Win32 API can often get twice the result with half the effort.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.