Solved

Getting cookies from the InternetExplorer

Posted on 2004-09-21
9
497 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
convert do-while to for-loop 10 213
RPC and IDL: Example on how to use the MS-RSP protocol ? 6 118
.Net Errors Service Crashing 5 130
mixing C++ & C# in Vis Studio 2013 7 198
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

839 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