Read all cookies?

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

Would I be right in saying that there are no classes in .Net to read and
parse all the cookies on a PC (not just those associated with a particular
session), and that if I wanted to list them all (along with all the values),
I'd have to parse them manually from the cookies directory? The latter's not
too hard, but it's always nice of someone's already done the hard work for
you. :-)
 
Mark said:
Would I be right in saying that there are no classes in .Net to read
and parse all the cookies on a PC (not just those associated with a
particular session), and that if I wanted to list them all (along
with all the values), I'd have to parse them manually from the
cookies directory? The latter's not too hard, but it's always nice of
someone's already done the hard work for you. :-)

There's a Win32 API to parse all IE cookies:

[DllImport("wininet.dll", CharSet=CharSet.Auto, SetLastError=true)]
extern static bool InternetGetCookie (
string urlName,
string cookieName,
StringBuilder cookieData,
ref int size);

YOu'll probably find similar Mozilla APIs for Firefox/Mozilla.

Cheers,
 
Joerg Jooss said:
Mark said:
Would I be right in saying that there are no classes in .Net to read
and parse all the cookies on a PC (not just those associated with a
particular session), and that if I wanted to list them all (along
with all the values), I'd have to parse them manually from the
cookies directory? The latter's not too hard, but it's always nice of
someone's already done the hard work for you. :-)

There's a Win32 API to parse all IE cookies:

[DllImport("wininet.dll", CharSet=CharSet.Auto, SetLastError=true)]
extern static bool InternetGetCookie (
string urlName,
string cookieName,
StringBuilder cookieData,
ref int size);

YOu'll probably find similar Mozilla APIs for Firefox/Mozilla.

Perfect - thanks very much. :-)
 
Mark said:
Joerg Jooss said:
Mark said:
Would I be right in saying that there are no classes in .Net to read
and parse all the cookies on a PC (not just those associated with a
particular session), and that if I wanted to list them all (along
with all the values), I'd have to parse them manually from the
cookies directory? The latter's not too hard, but it's always nice of
someone's already done the hard work for you. :-)

There's a Win32 API to parse all IE cookies:

[DllImport("wininet.dll", CharSet=CharSet.Auto, SetLastError=true)]
extern static bool InternetGetCookie (
string urlName,
string cookieName,
StringBuilder cookieData,
ref int size);

YOu'll probably find similar Mozilla APIs for Firefox/Mozilla.

I tried this out and as far as I can tell, InternetGetCookie expects a URL
as one of the arguments. So, I have to know the URL to start with which
means retrieving it manually from each cookie one by one. However, if I'm
going to do that I might as well parse the whole cookie and forget about
InternetGetCookie, I think. Is this right?

Perfect - thanks very much. :-)
 
Back
Top