Discussion:
Get Cookies from Memory w/o knowing names?
(too old to reply)
Nathan
2004-06-24 12:38:01 UTC
Permalink
Is there a way I can grab session cookies from memory without knowing their names? I've written an app that uses winsock to communicate with a web server and extract cookies. I then use the webbrowser control for a few pages. So, I used InternetSetCookie to set the cookies I extracted with winsock into memory to use with the webbrowser control. Now, After using the browser, I need my app to go back to winsock OR wininet to communicate with the web server. However, the browser automatically handles cookies and I'm not sure how to get the new cookies out of memory that were sent to the browser for the 2 pages that it browses.
Any ideas? Is there a way to use InternetGetCookie to retrieve all cookies?
Brian Combs
2004-06-25 21:57:06 UTC
Permalink
Hello
If you know the URL that they used in the webbrowser control you can use
InternetGetCookie for any cookies that are for that domain.
InternetGetCookie("http://mysite.com", NULL, szBuff, &dwSizeBuff);
You can then use the return szBuff in your socket calls to send back the
cookies.

Thanks
Brian [MSFT]
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| Thread-Topic: Get Cookies from Memory w/o knowing names?
| thread-index: AcRZ6BaMyh0VzXnGRwq0PGO18sofkA==
| X-WBNR-Posting-Host: 67.37.109.10
| From: =?Utf-8?B?TmF0aGFu?= <***@discussions.microsoft.com>
| Subject: Get Cookies from Memory w/o knowing names?
| Date: Thu, 24 Jun 2004 05:38:01 -0700
| Lines: 2
| Message-ID: <0175824F-C57C-4BDD-B309-***@microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.inetsdk.programming.wininet
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 127.0.0.1
| Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: cpmsftngxa10.phx.gbl
microsoft.public.inetsdk.programming.wininet:11501
| X-Tomcat-NG: microsoft.public.inetsdk.programming.wininet
|
| Is there a way I can grab session cookies from memory without knowing
their names? I've written an app that uses winsock to communicate with a
web server and extract cookies. I then use the webbrowser control for a
few pages. So, I used InternetSetCookie to set the cookies I extracted
with winsock into memory to use with the webbrowser control. Now, After
using the browser, I need my app to go back to winsock OR wininet to
communicate with the web server. However, the browser automatically
handles cookies and I'm not sure how to get the new cookies out of memory
that were sent to the browser for the 2 pages that it browses.
| Any ideas? Is there a way to use InternetGetCookie to retrieve all
cookies?
|
Brian Combs
2004-06-30 20:31:29 UTC
Permalink
Hello
From the MSDN on InternetGetCookie:
InternetGetCookie does not require a call to InternetOpen.
InternetGetCookie checks in the windows\cookies directory for persistent
cookies that have an expiration date set sometime in the future.
InternetGetCookie also searches memory for any session cookies (cookies
that do not have an expiration date) that were created in the same process
by InternetSetCookie, since these cookies are not written to any files.
Rules for creating cookie files are internal to the system and can change
in the future.


Thanks
Brian [MSFT]
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| Thread-Topic: Get Cookies from Memory w/o knowing names?
| thread-index: AcRdI/F54bA8m8pGQAOLGyi6PeDzrw==
| X-WBNR-Posting-Host: 67.37.109.10
| From: =?Utf-8?B?TmF0aGFu?= <***@discussions.microsoft.com>
| References: <0175824F-C57C-4BDD-B309-***@microsoft.com>
<***@cpmsftngxa10.phx.gbl>
| Subject: RE: Get Cookies from Memory w/o knowing names?
| Date: Mon, 28 Jun 2004 08:24:02 -0700
| Lines: 54
| Message-ID: <CC837C0A-89CE-4360-BA8B-***@microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.inetsdk.programming.wininet
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 127.0.0.1
| Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: cpmsftngxa10.phx.gbl
microsoft.public.inetsdk.programming.wininet:11514
| X-Tomcat-NG: microsoft.public.inetsdk.programming.wininet
|
| Do you know if that grabs the cookies out of memory for that URL or if it
actually hits the URL and tries to get the cookies? I'm pretty sure the
cookies have a unique value and if it hit the URL again for cookies, I
would get a cookie with a different value.
|
| "Brian Combs" wrote:
|
| > Hello
| > If you know the URL that they used in the webbrowser control you can
use
| > InternetGetCookie for any cookies that are for that domain.
| > InternetGetCookie("http://mysite.com", NULL, szBuff, &dwSizeBuff);
| > You can then use the return szBuff in your socket calls to send back
the
| > cookies.
| >
| > Thanks
| > Brian [MSFT]
| > Microsoft Developer Support
| > This posting is provided "AS IS" with no warranties, and confers no
rights.
| > --------------------
| > | Thread-Topic: Get Cookies from Memory w/o knowing names?
| > | thread-index: AcRZ6BaMyh0VzXnGRwq0PGO18sofkA==
| > | X-WBNR-Posting-Host: 67.37.109.10
| > | From: =?Utf-8?B?TmF0aGFu?= <***@discussions.microsoft.com>
| > | Subject: Get Cookies from Memory w/o knowing names?
| > | Date: Thu, 24 Jun 2004 05:38:01 -0700
| > | Lines: 2
| > | Message-ID: <0175824F-C57C-4BDD-B309-***@microsoft.com>
| > | MIME-Version: 1.0
| > | Content-Type: text/plain;
| > | charset="Utf-8"
| > | Content-Transfer-Encoding: 7bit
| > | X-Newsreader: Microsoft CDO for Windows 2000
| > | Content-Class: urn:content-classes:message
| > | Importance: normal
| > | Priority: normal
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| > | Newsgroups: microsoft.public.inetsdk.programming.wininet
| > | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 127.0.0.1
| > | Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| > | Xref: cpmsftngxa10.phx.gbl
| > microsoft.public.inetsdk.programming.wininet:11501
| > | X-Tomcat-NG: microsoft.public.inetsdk.programming.wininet
| > |
| > | Is there a way I can grab session cookies from memory without knowing
| > their names? I've written an app that uses winsock to communicate with
a
| > web server and extract cookies. I then use the webbrowser control for
a
| > few pages. So, I used InternetSetCookie to set the cookies I extracted
| > with winsock into memory to use with the webbrowser control. Now,
After
| > using the browser, I need my app to go back to winsock OR wininet to
| > communicate with the web server. However, the browser automatically
| > handles cookies and I'm not sure how to get the new cookies out of
memory
| > that were sent to the browser for the 2 pages that it browses.
| > | Any ideas? Is there a way to use InternetGetCookie to retrieve all
| > cookies?
| > |
| >
| >
|

Continue reading on narkive:
Loading...