Solved

Getting cookies from the InternetExplorer

Posted on 2004-09-21
9
501 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

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…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

749 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