Solved

Getting cookies from the InternetExplorer

Posted on 2004-09-21
9
470 Views
Last Modified: 2012-08-14
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::GetCookie() 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
0
Comment
Question by:tdomega
  • 3
  • 2
  • 2
  • +1
9 Comments
 
LVL 6

Expert Comment

by:Svetlin_Panayotov
Comment Utility
You can try searching the cookie directory - it is different in Win9x/NT - and retrieving the names from there.It can be a somehow complicated - you must check OS version, logged user etc. and then construct your path.After you get the names InternetGetCookie() seems to be working fine with them.

Svetlin
0
 

Author Comment

by:tdomega
Comment Utility
I tried it with the function InternetGetCookie(url,cookiename,cookiedata,size);

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++?
0
 
LVL 16

Expert Comment

by:nonubik
Comment Utility
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
0
 

Author Comment

by:tdomega
Comment Utility
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.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 6

Expert Comment

by:Svetlin_Panayotov
Comment Utility
           LPTSTR lpData = new char[512];
            ZeroMemory(lpData,sizeof(lpData));
            DWORD dwSize = 512;
            BOOL bResult;
            bResult = InternetGetCookie("http://www.experts-exchange.com",NULL,lpData,&dwSize);
            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
0
 
LVL 6

Expert Comment

by:Svetlin_Panayotov
Comment Utility
Sorry sometimes the page doesn't refresh - couldn't see you solved it.
0
 
LVL 16

Expert Comment

by:nonubik
Comment Utility
tdomega, you'll have to post a question in 'Community Support' TA in order to close the question.
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VisualC_PLUS_PLUS_DOT_NET/help.jsp#hi70
0
 

Accepted Solution

by:
ee_ai_construct earned 0 total points
Comment Utility
Closed, 500 points refunded.
ee_ai_construct (replacement part #xm34)
Community Support Admin
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

728 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

9 Experts available now in Live!

Get 1:1 Help Now