Re: C++ to read cookies created by local HTML file
- From: "Susan Kong" <susan@xxxxxxxxxxxxxx>
- Date: Wed, 12 Apr 2006 12:59:19 +0800
Here is my code, almost the same as MSDN sample.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wininet/win
inet/managing_cookies.asp
programs always goes to this line:
::AfxMessageBox(" other error!"); // this is the line I always get.
Thanks a lot if anybody can give a look through.
BOOL bReturn;
// Create a session cookie.
bReturn = InternetSetCookie("http://www.mysite.com", NULL,
"TestData = Test");
// Create a persistent cookie.
bReturn = InternetSetCookie("http://www.mysite.com", NULL,
"TestData = Test; expires = Sat,01-Jan-2006 00:00:00 GMT");
char szURL[256]="http://www.mysite.com"; // buffer to hold the URL
LPSTR lpszData = NULL; // buffer to hold the cookie data
DWORD dwSize=0; // variable to get the buffer size needed
// Insert code to retrieve the URL.
retry:
// The first call to InternetGetCookie will get the required
// buffer size needed to download the cookie data.
if (!InternetGetCookie(szURL, NULL, lpszData, &dwSize))
{
// Check for an insufficient buffer error.
if (GetLastError()== ERROR_INSUFFICIENT_BUFFER)
{
// Allocate the necessary buffer.
lpszData = new char[dwSize];
::AfxMessageBox(" ERROR_INSUFFICIENT_BUFFER!");
// Try the call again.
goto retry;
}
else
{
// Insert error handling code.
::AfxMessageBox(" other error!"); // this is the line I always get.
}
}
else
{
// Insert code to display the cookie data.
::AfxMessageBox(lpszData);
// Release the memory allocated for the buffer.
delete[]lpszData;
}
regards,
Susan
"Voidcoder" <voidcoder@xxxxxxxxx> wrote in message
news:e4nSkwUXGHA.1192@xxxxxxxxxxxxxxxxxxxxxxx
Both InternetGetCookie / InternetSetCookie work as expected,news:uxACBIUXGHA.3936@xxxxxxxxxxxxxxxxxxxxxxx
something is wrong with your code.
"Susan Kong" <susan@xxxxxxxxxxxxxx> wrote in message
byHI,
I'm using VS2003, C++. I tried to retrieve the cookies which are created
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wininet/wina local HTML file with JavaScript. I read the article:
alwaysinet/managing_cookies.asp
and copy the code. Unfortunately, the retrieved cookie strings are
codeempty.
Anyone can shed some light on this or lead me somewhere with C++ CGI
stuff?
Thanks in advance.
Susan
.
- Follow-Ups:
- Re: C++ to read cookies created by local HTML file
- From: Jeff Partch [MVP]
- Re: C++ to read cookies created by local HTML file
- From: Voidcoder
- Re: C++ to read cookies created by local HTML file
- References:
- C++ to read cookies created by local HTML file
- From: Susan Kong
- Re: C++ to read cookies created by local HTML file
- From: Voidcoder
- C++ to read cookies created by local HTML file
- Prev by Date: Re: VS 6.0 dialogs in the VS 8.0
- Next by Date: Re: Need help understanding passing pointers between threads.
- Previous by thread: Re: C++ to read cookies created by local HTML file
- Next by thread: Re: C++ to read cookies created by local HTML file
- Index(es):
Relevant Pages
|