Internetgetcookie/internetsetcookie (wininet) changed with Internet Explorer 7

Source: Internet
Author: User
Tags idn set cookie
Internetgetcookie/internetsetcookie (wininet) changed with Internet Explorer 7 by YEEP

So last week I was implementing the Google authentication for installed applications in feed vortex and after I solved the cross-thread GUI access problems I ran into a new batch of problems. you see, Google authenticates using cookies, but when you use the Google authentication API for desktop applications you only get the value that needs to be stored in the cookie and not the cookie itself. since I p/invoke the wininet functions, I needed to store the cookie using the internetsetcookie API and then the wininet APIs themselves will figure out what Cookie to get.

But it wasn' t so simple. using fire fox I noticed that Google stores its cookies with the domain ".google.com" and the path "/". but when I try to do that I get error 12006 (error_internet_unrecognized_scheme ). allright, So I add "http: //" to the front, but then I confronted with error 123 (error_invalid_name ). this confused me. but then I remembered I was running IE7 beta 3 on my desktop, so I put the code on my laptop which still uses goold old IE6 and it works.

One of the changes for IE7 is their more secure URL cracking methods. But apparently IE7 also updates the wininet. dll, which other applications use. So it's new security fixesWill have effect on other applications, Not just applications that use an embedded IE,All applications that use wininet. So I spend half a day figuring out what do. And in the end I found out that using "http://www.google.com" as the cookie domain works as well.

[Now playing: The project hate mcmxcix-with desperate hands so numb]

This entry is filed under programming. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

One response to "internetgetcookie/internetsetcookie (wininet) changed with Internet Explorer 7"

1

Ari pernick [MSFT] Says: July 25th, 2006

Thank you for describing your experiences. to figure out what is going on in this API it helps to understood how the API is used by IE, specifically that the URL field is the URL that the user navigates to when browsing to a site. the .google.com field you mention is in the cookie data. the Set cookie API takes the URL and the cookie data and figures out what domain and path are and then does a security check that domain matches the URL's domain. when figuring out the domain and path, the cookie data gets priority over what comes out of the URL. the API assumes that the URL is a valid URL, so you need a scheme and host and everything else. the behavior of the API when you don't pass in a valid URL is undefined. it happens that with IE7's support for IDN we actually test the URL hostname's validity more in the Unicode API (because we need to convert the hostname to IDN form ).

since you have the cookie and you aren't actually naviagting to a site, you need to make up a URL that matches the cookie.

Related Article

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.