Solved

Reading a Web cookie from my app

Posted on 1997-05-01
3
1,090 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
  • 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now