Read all cookies?

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. :)
 
J

Joerg Jooss

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,
 
M

Mark

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. :)
 
M

Mark

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. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top