Solved

Reading a Web cookie from my app

Posted on 1997-05-01
3
1,120 Views
Last Modified: 2013-12-04
Hi,

I'm trying to read a cookie written by script embedded in an HTML page from a C++ application. I tried to use the InternetGetCookie() function (defined in wininet.h) but it always fails. GetLastError() returns the value:
ERROR_NO_MORE_ITEMS
which winerror.h defines as: "No more data is available." Presumably I'm giving this function an incorrect parameter but after trying every combination I could think of, nothing works.

I've checked the actual cookie directory and the cookie data does get written. I can write the code to read it myself  but I’d like to avoid the hassle. Also, I'm afraid that the cookie format may change.

I'm using VC++ 5 and IE4.
Any help would be appreciated.

Dan
0
Comment
Question by:shappir
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
emmons earned 200 total points
ID: 1397053
SInce you are getting ERROR_NO_MORE_ITEMS, I assume that you are failing to match any cookies in the cache (in the absence of your code+the cookie this is a start)
So, according to the spec, the URL matches if and only if:

* both host names are IP addresses and their host name
  strings match exactly; or

* both host names are FQDN strings and their host name strings
   match exactly; or

* A is a FQDN string and has the form NB, where N is a
  non-empty name string, B has the form .B', and B' is a FQDN
  string.  (So, x.y.com domain-matches .y.com but not y.com.)

This last one is the one that caught me. Do you have the request beginning with a period?

The parameters to the function are straightforward other than the syntax of the URL,
BOOL InternetGetCookie(
      IN LPCSTR lpszUrlName,
      IN LPCSTR lpszCookieName,
      OUT LPSTR lpszCookieData,
      IN OUT LPDWORD lpdwSize );

and lpszCookieName should be NULL.
0
 

Expert Comment

by:dcass
ID: 13530169
Is this c#?  It won't compile and I have the same problem.  I'm new at this though.
Where are the variables?  i.e. where is the cookie data if I do get it to compile?
0
 
LVL 4

Expert Comment

by:emmons
ID: 13630315
No, it is not c#.  The answer was from 1997!
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question