restoring cookies

  • Thread starter Thread starter Denis @ TheOffice
  • Start date Start date
D

Denis @ TheOffice

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

Denis Co
 
Denis @ TheOffice said:
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
 
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 said:
Denis @ TheOffice said:
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 said:
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
 
I see :
InternetGetCookie (_T("my.yahoo.com"), NULL, (LPTSTR)&Buffer, &CookieSize);

I do not know what to put as Name?

Denis
 
Denis @ TheOffice said:
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.
--
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
 
Oops!

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

???
 
Denis @ TheOffice said:
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?
--
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 said:
Denis @ TheOffice said:
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.
--
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
 
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 said:
Igor Tandetnik said:
Denis @ TheOffice said:
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.
--
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 said:
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
 
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
 
Denis @ TheOffice said:
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
 
Tanks,

Your help was most grateful.

Denis

Igor Tandetnik said:
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
 
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
 
Denis @ TheOffice said:
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
 
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 said:
Denis @ TheOffice said:
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 said:
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.
--
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
 
Thanks again.

Denis

Igor Tandetnik said:
Right. You can use InternetTimeFromSystemTime to format the time string.


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
 
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
 
Back
Top