Solved

Getting cookies from the InternetExplorer

Posted on 2004-09-21
9
489 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
ID: 12120431
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
ID: 12121708
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
ID: 12121806
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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Author Comment

by:tdomega
ID: 12121862
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
 
LVL 6

Expert Comment

by:Svetlin_Panayotov
ID: 12121901
           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
ID: 12121913
Sorry sometimes the page doesn't refresh - couldn't see you solved it.
0
 
LVL 16

Expert Comment

by:nonubik
ID: 12124908
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
ID: 12155641
Closed, 500 points refunded.
ee_ai_construct (replacement part #xm34)
Community Support Admin
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

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…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

816 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