tdomega
asked on
Getting cookies from the InternetExplorer
Hi,
Im writing a little webclient for http-sites. I want to use the cookies from InternetExplorer(6.0) since that is used as the main browser...
I need to get the cookies somehow. I tried it with InternetGetCookie, but it alwys fails. (returns false, but no errorcode). I also played with CInternetSession::GetCooki e() but the same.
So how do I get all the cookies on site may have set from the InternetExplorers cache without knowing the name of the cookie?
And a second question, if i want to get subdomains, do i have to send the cookie from the topdomain too?
Thanks for any help :)
-Stephan
Im writing a little webclient for http-sites. I want to use the cookies from InternetExplorer(6.0) since that is used as the main browser...
I need to get the cookies somehow. I tried it with InternetGetCookie, but it alwys fails. (returns false, but no errorcode). I also played with CInternetSession::GetCooki
So how do I get all the cookies on site may have set from the InternetExplorers cache without knowing the name of the cookie?
And a second question, if i want to get subdomains, do i have to send the cookie from the topdomain too?
Thanks for any help :)
-Stephan
ASKER
I tried it with the function InternetGetCookie(url,cook iename,coo kiedata,si ze);
when I used it from VisualBasic it worked (was some years ago though) now it doesnt from c++.
And I dont think I need the cookie name (didnt need it under VB either) since the msdn says lpszCookieName : [in] Not implemented. So this function should actually get me all cookies from this site (did so in VB). So now Im wondering why it worked at that time but now fails under c++?
when I used it from VisualBasic it worked (was some years ago though) now it doesnt from c++.
And I dont think I need the cookie name (didnt need it under VB either) since the msdn says lpszCookieName : [in] Not implemented. So this function should actually get me all cookies from this site (did so in VB). So now Im wondering why it worked at that time but now fails under c++?
How does it fail? please post some code.
Maybe it's related to tihs: http://support.microsoft.com/default.aspx?scid=kb;en-us;306354
Maybe it's related to tihs: http://support.microsoft.com/default.aspx?scid=kb;en-us;306354
ASKER
Hi,
solved it :)
was a dumb error...the url InternetGetCookie wants has to start with http:// and i just used www.google.com.
sorry, my bad...
Thanks for all your help.
solved it :)
was a dumb error...the url InternetGetCookie wants has to start with http:// and i just used www.google.com.
sorry, my bad...
Thanks for all your help.
LPTSTR lpData = new char[512];
ZeroMemory(lpData,sizeof(l pData));
DWORD dwSize = 512;
BOOL bResult;
bResult = InternetGetCookie("https://www.experts-exchange.com",NULL, lpData,&dw Size);
if (!bResult)
{
DWORD errCode = GetLastError();
printf("An error occured: %d", errCode);
}
else
{
printf("Cookie data: %s\n",lpData);
}
getch();
delete[] lpData;
The code above works well for me and retrieves the cookie.
Svetlin
ZeroMemory(lpData,sizeof(l
DWORD dwSize = 512;
BOOL bResult;
bResult = InternetGetCookie("https://www.experts-exchange.com",NULL,
if (!bResult)
{
DWORD errCode = GetLastError();
printf("An error occured: %d", errCode);
}
else
{
printf("Cookie data: %s\n",lpData);
}
getch();
delete[] lpData;
The code above works well for me and retrieves the cookie.
Svetlin
Sorry sometimes the page doesn't refresh - couldn't see you solved it.
tdomega, you'll have to post a question in 'Community Support' TA in order to close the question.
https://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VisualC_PLUS_PLUS_DOT_NET/help.jsp#hi70
https://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VisualC_PLUS_PLUS_DOT_NET/help.jsp#hi70
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Svetlin