Discussion:
restoring cookies
(too old to reply)
Denis @ TheOffice
2006-07-21 19:22:47 UTC
Permalink
I would need to forcibly save and restore cookies while IE is running.
Is there a way to program that ?

Denis Co
Igor Tandetnik
2006-07-22 00:17:21 UTC
Permalink
Post by Denis @ TheOffice
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
2006-07-27 17:10:34 UTC
Permalink
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
Post by Igor Tandetnik
Post by Denis @ TheOffice
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
Igor Tandetnik
2006-07-27 17:38:59 UTC
Permalink
Post by Denis @ TheOffice
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
--
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
2006-07-27 20:27:35 UTC
Permalink
I see :
InternetGetCookie (_T("my.yahoo.com"), NULL, (LPTSTR)&Buffer, &CookieSize);

I do not know what to put as Name?

Denis
Post by Igor Tandetnik
Post by Denis @ TheOffice
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
--
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
Igor Tandetnik
2006-07-27 20:45:46 UTC
Permalink
Post by Denis @ TheOffice
InternetGetCookie (_T("my.yahoo.com"), NULL,
(LPTSTR)&Buffer, &CookieSize);
How is Buffer declared? If you have to cast, you probably got it wrong.
Post by Denis @ TheOffice
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.
--
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
2006-07-27 21:04:17 UTC
Permalink
Oops!

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

???
Post by Igor Tandetnik
Post by Denis @ TheOffice
InternetGetCookie (_T("my.yahoo.com"), NULL,
(LPTSTR)&Buffer, &CookieSize);
How is Buffer declared? If you have to cast, you probably got it wrong.
Post by Denis @ TheOffice
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.
--
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
Igor Tandetnik
2006-07-27 21:05:16 UTC
Permalink
Post by Denis @ TheOffice
I just changed &Buffer to Buffer but it is still the same...
BYTE Buffer [(64 * KB)];
Do you initialize CookieSize to the length of the buffer before calling
the function?
--
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
Igor Tandetnik
2006-07-27 21:11:22 UTC
Permalink
Post by Igor Tandetnik
Post by Denis @ TheOffice
I just changed &Buffer to Buffer but it is still the same...
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.
--
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
2006-07-27 22:17:12 UTC
Permalink
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?
Post by Igor Tandetnik
Post by Igor Tandetnik
Post by Denis @ TheOffice
I just changed &Buffer to Buffer but it is still the same...
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.
--
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
Igor Tandetnik
2006-07-27 22:44:24 UTC
Permalink
Post by Denis @ TheOffice
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"
--
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
2006-07-28 15:41:27 UTC
Permalink
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
Post by Igor Tandetnik
Post by Denis @ TheOffice
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"
--
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
Igor Tandetnik
2006-07-28 15:45:27 UTC
Permalink
Post by Denis @ TheOffice
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.
--
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
2006-07-28 16:21:23 UTC
Permalink
Tanks,

Your help was most grateful.

Denis
Post by Igor Tandetnik
Post by Denis @ TheOffice
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.
--
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
2006-07-31 17:34:02 UTC
Permalink
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
Post by Igor Tandetnik
Post by Denis @ TheOffice
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.
--
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
Igor Tandetnik
2006-07-31 19:25:31 UTC
Permalink
Post by Denis @ TheOffice
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
--
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
2006-07-31 20:30:36 UTC
Permalink
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
Post by Igor Tandetnik
Post by Denis @ TheOffice
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
--
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
Igor Tandetnik
2006-07-31 20:44:14 UTC
Permalink
Post by Denis @ TheOffice
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.
Post by Denis @ TheOffice
And Is this the only thing I am going to need?
I believe so.
--
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
2006-07-31 21:05:05 UTC
Permalink
Thanks again.

Denis
Post by Igor Tandetnik
Post by Denis @ TheOffice
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.
Post by Denis @ TheOffice
And Is this the only thing I am going to need?
I believe so.
--
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
2006-08-01 15:06:07 UTC
Permalink
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
Post by Igor Tandetnik
Post by Denis @ TheOffice
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.
Post by Denis @ TheOffice
And Is this the only thing I am going to need?
I believe so.
--
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
Igor Tandetnik
2006-08-01 18:29:50 UTC
Permalink
Post by Denis @ TheOffice
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.
--
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
2006-08-03 19:50:34 UTC
Permalink
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
Post by Igor Tandetnik
Post by Denis @ TheOffice
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.
--
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
2006-08-01 18:40:36 UTC
Permalink
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
Post by Igor Tandetnik
Post by Denis @ TheOffice
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.
Post by Denis @ TheOffice
And Is this the only thing I am going to need?
I believe so.
--
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
Manjeet Dahiya
2006-09-29 09:51:33 UTC
Permalink
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
Post by Denis @ TheOffice
I am still having problem restoring Yahoo.com with personalization.
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
Post by Igor Tandetnik
Post by Denis @ TheOffice
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.
Post by Denis @ TheOffice
And Is this the only thing I am going to need?
I believe so.
--
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
Igor Tandetnik
2006-09-29 12:08:28 UTC
Permalink
Post by Manjeet Dahiya
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]
--
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
Loading...