Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

restoring cookies

9 views
Skip to first unread message

Denis @ TheOffice

unread,
Jul 21, 2006, 3:22:47 PM7/21/06
to
I would need to forcibly save and restore cookies while IE is running.
Is there a way to program that ?

Denis Co


Igor Tandetnik

unread,
Jul 21, 2006, 8:17:21 PM7/21/06
to
"Denis @ TheOffice" <den...@ica.net> wrote in message
news:11535095...@www.vif.com

> I would need to forcibly save and restore cookies while IE is running.
> Is there a way to program that ?

InternetGetCookie[Ex], InternetSetCookie[Ex], FindFirstUrlCacheEntry[Ex]
et al
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


Denis @ TheOffice

unread,
Jul 27, 2006, 1:10:34 PM7/27/06
to
Thanks,
Sorry for the delay.

I just did the code Which consist of an enumeration and retreival,
But InternetGetCookie does not seems to work.
The enumeration (FindFirstUrlCacheEntry) works though.

Perhaps, I do not understand how to use it properly?
I had a GetLastError of (998) ERROR_NOACCESS


Any help or sample code of usage would be greatly appreciated.
Thanks.
Denis

"Igor Tandetnik" <itand...@mvps.org> wrote in message news:OQdD0QS...@TK2MSFTNGP03.phx.gbl...

Igor Tandetnik

unread,
Jul 27, 2006, 1:38:59 PM7/27/06
to
Denis @ TheOffice <den...@ica.net> wrote:
> I just did the code Which consist of an enumeration and retreival,
> But InternetGetCookie does not seems to work.
> The enumeration (FindFirstUrlCacheEntry) works though.
>
> Perhaps, I do not understand how to use it properly?
> I had a GetLastError of (998) ERROR_NOACCESS

ERROR_NOACCESS means you are passing a NULL or invalid pointer. Show how
you call InternetGetCookie

Denis @ TheOffice

unread,
Jul 27, 2006, 4:27:35 PM7/27/06
to
I see :
InternetGetCookie (_T("my.yahoo.com"), NULL, (LPTSTR)&Buffer, &CookieSize);

I do not know what to put as Name?

Denis

"Igor Tandetnik" <itand...@mvps.org> wrote in message news:e%23KfJmas...@TK2MSFTNGP05.phx.gbl...

Igor Tandetnik

unread,
Jul 27, 2006, 4:45:46 PM7/27/06
to
Denis @ TheOffice <den...@ica.net> wrote:
> I see :
> InternetGetCookie (_T("my.yahoo.com"), NULL,
> (LPTSTR)&Buffer, &CookieSize);

How is Buffer declared? If you have to cast, you probably got it wrong.

> I do not know what to put as Name?

You mean the second parameter? The documentation says "Not implemented",
so any value should do. NULL is perfectly fine.

Denis @ TheOffice

unread,
Jul 27, 2006, 5:04:17 PM7/27/06
to
Oops!

I just changed &Buffer to Buffer but it is still the same...
Buffer is define as this:
BYTE Buffer [(64 * KB)];

???


"Igor Tandetnik" <itand...@mvps.org> wrote in message news:uTSij2bs...@TK2MSFTNGP04.phx.gbl...

Igor Tandetnik

unread,
Jul 27, 2006, 5:05:16 PM7/27/06
to
Denis @ TheOffice <den...@ica.net> wrote:
> I just changed &Buffer to Buffer but it is still the same...
> Buffer is define as this:
> BYTE Buffer [(64 * KB)];

Do you initialize CookieSize to the length of the buffer before calling
the function?

Igor Tandetnik

unread,
Jul 27, 2006, 5:11:22 PM7/27/06
to
Igor Tandetnik <itand...@mvps.org> wrote:
> Denis @ TheOffice <den...@ica.net> wrote:
>> I just changed &Buffer to Buffer but it is still the same...
>> Buffer is define as this:
>> BYTE Buffer [(64 * KB)];
>
> Do you initialize CookieSize to the length of the buffer before
> calling the function?

Note that the size should be in TCHARs, not in BYTEs. TCHAR may be 1 or
2 bytes depending on whether you build ANSI or Unicode build.

Denis @ TheOffice

unread,
Jul 27, 2006, 6:17:12 PM7/27/06
to
I am in unicode so...
I have divide the CookieSize by 2 - 2;
still no luck???

This time I had an error of 12006 which is not define in error lookup.

I even try to place the call at the begening of the software...
Not working ...

Hummm! What do you think?


"Igor Tandetnik" <itand...@mvps.org> wrote in message news:uZMqJJcs...@TK2MSFTNGP02.phx.gbl...

Igor Tandetnik

unread,
Jul 27, 2006, 6:44:24 PM7/27/06
to
Denis @ TheOffice <den...@ica.net> wrote:
> I am in unicode so...
> I have divide the CookieSize by 2 - 2;
> still no luck???
>
> This time I had an error of 12006 which is not define in error lookup.

That would be ERROR_INTERNET_UNRECOGNIZED_SCHEME. You are passing
"my.yahoo.com" as the first parameter - make it "http://my.yahoo.com"

Denis @ TheOffice

unread,
Jul 28, 2006, 11:41:27 AM7/28/06
to
Yes!


It worked finally.


Thank you very much.

On a side subject:

I need to stores/retrieves cookies independently of the user name created in windows.
Example: Let say I create the user 00001 and saves its cookies.
Then later I would call that user 00002 and restore it's cookies from 00001 for example.

In your opinion would my strategy old ?

Regards,
Denis


"Igor Tandetnik" <itand...@mvps.org> wrote in message news:ur$xH6csG...@TK2MSFTNGP03.phx.gbl...

Igor Tandetnik

unread,
Jul 28, 2006, 11:45:27 AM7/28/06
to
Denis @ TheOffice <den...@ica.net> wrote:
> I need to stores/retrieves cookies independently of the user name
> created in windows.
> Example: Let say I create the user 00001 and saves its cookies.
> Then later I would call that user 00002 and restore it's cookies from
> 00001 for example.

InternetGetCookie, InternetSetCookie et al use the cookie store of
whatever user account your process is running under. So you can
impersonate one user, read all her cookies and store them somewhere,
then impersonate another user and set cookies on her behalf.

Denis @ TheOffice

unread,
Jul 28, 2006, 12:21:23 PM7/28/06
to
Tanks,

Your help was most grateful.

Denis

"Igor Tandetnik" <itand...@mvps.org> wrote in message news:%23r7fazl...@TK2MSFTNGP04.phx.gbl...

Denis @ TheOffice

unread,
Jul 31, 2006, 1:34:02 PM7/31/06
to
I have been trying.
There another issue, that perhaps you can help me.

On yahoo, I setup a personal page and normally it recognizes me.

When I use those routines it does not?


Plus I can see the cookies in the cookies folder. When I use the routine it does not?

Thanks,
Denis


"Igor Tandetnik" <itand...@mvps.org> wrote in message news:%23r7fazl...@TK2MSFTNGP04.phx.gbl...

Igor Tandetnik

unread,
Jul 31, 2006, 3:25:31 PM7/31/06
to
Denis @ TheOffice <den...@ica.net> wrote:
> On yahoo, I setup a personal page and normally it recognizes me.
>
> When I use those routines it does not?
>
>
> Plus I can see the cookies in the cookies folder. When I use the
> routine it does not?

Do you set persistent cookies? That is, does the cookie value passed to
InternetSetCookie[Ex] have expires= clause? Without such a clause, you
are setting a session cookie - temporary in-memory cookie that is only
active within your process. For an example, see

http://msdn.microsoft.com/library/en-us/wininet/wininet/managing_cookies.asp

Denis @ TheOffice

unread,
Jul 31, 2006, 4:30:36 PM7/31/06
to
Right now I am just Storing them as I got them from InternetGetCookie.

I am guessing That I have to add a line saying for how long from FindFirstUrlCacheEntry().
in the structure INTERNET_CACHE_ENTRY_INFO
Is this right?
And Is this the only thing I am going to need?

Thanks,
Denis


"Igor Tandetnik" <itand...@mvps.org> wrote in message news:Op6lVcNt...@TK2MSFTNGP03.phx.gbl...

Igor Tandetnik

unread,
Jul 31, 2006, 4:44:14 PM7/31/06
to
Denis @ TheOffice <den...@ica.net> wrote:
> Right now I am just Storing them as I got them from InternetGetCookie.
>
> I am guessing That I have to add a line saying for how long from
> FindFirstUrlCacheEntry().
> in the structure INTERNET_CACHE_ENTRY_INFO
> Is this right?

Right. You can use InternetTimeFromSystemTime to format the time string.

> And Is this the only thing I am going to need?

I believe so.

Denis @ TheOffice

unread,
Jul 31, 2006, 5:05:05 PM7/31/06
to
Thanks again.

Denis

"Igor Tandetnik" <itand...@mvps.org> wrote in message news:uJs3cIOt...@TK2MSFTNGP03.phx.gbl...

Denis @ TheOffice

unread,
Aug 1, 2006, 11:06:07 AM8/1/06
to
BTW...

Right now I am truncanating the user name@ and replace it by "http://"
Is there any cases where that should be "https://" if yes how would I know?

Regards,
Denis

"Igor Tandetnik" <itand...@mvps.org> wrote in message news:uJs3cIOt...@TK2MSFTNGP03.phx.gbl...

Igor Tandetnik

unread,
Aug 1, 2006, 2:29:50 PM8/1/06
to
Denis @ TheOffice <den...@ica.net> wrote:
> Right now I am truncanating the user name@ and replace it by "http://"
> Is there any cases where that should be "https://" if yes how would I
> know?

By default, a cookie for a particular domain is sent to both HTTP and
HTTPS URLs in this domain. There exists a concept of secure cookie (one
that should only be sent over HTTPS): to set one, you append ";secure"
to the cookie data when calling InternetSetCookie. But I don't know how
to determine whether a particular cookie found in the cache is secure.

Denis @ TheOffice

unread,
Aug 1, 2006, 2:40:36 PM8/1/06
to
I am still having problem restoring Yahoo.com with personalization.

When I do:
Copy all files after log off, and recreate the user in another system restoring all files including index.dat.
It works.

When I try through those functions it does not restore properly.

I must be missing something?

Regards,
Denis


"Igor Tandetnik" <itand...@mvps.org> wrote in message news:uJs3cIOt...@TK2MSFTNGP03.phx.gbl...

Denis @ TheOffice

unread,
Aug 3, 2006, 3:50:34 PM8/3/06
to
Is there an alternative to InternetSetCookie, it seems it does not work?

in my trial code I realize InternetSetCookie changed the data (don't know why).

Regards,
Denis


"Igor Tandetnik" <itand...@mvps.org> wrote in message news:OA%23u6hZt...@TK2MSFTNGP03.phx.gbl...

Manjeet Dahiya

unread,
Sep 29, 2006, 5:51:33 AM9/29/06
to
Hi,

I want to edit the expire time, domain and other properties of the cookie.

What function can be used?

Thanks in advance.

Best regards,
Manjeet Dahiya

"Denis @ TheOffice" <den...@ica.net> wrote in message
news:11544574...@www.vif.com...

Igor Tandetnik

unread,
Sep 29, 2006, 8:08:28 AM9/29/06
to
"Manjeet Dahiya" <manjee...@gmail.com> wrote in message
news:%23VKHez6...@TK2MSFTNGP03.phx.gbl

> I want to edit the expire time, domain and other properties of the
> cookie.
> What function can be used?

You can't edit a cookie; you can delete an old one and create a new one
with desired parameters. InternetGetCookie[Ex], InternetSetCookie[Ex]

0 new messages