473,503 Members | 1,701 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Looping through the CookieContainer

Does anyone know how to loop through the CookieContainer to see each
individual cookie item?

Or is the CookieContainer just one variable with all the cookies in it?

TIA.
Nov 7 '07 #1
4 6435
From :
http://msdn2.microsoft.com/en-us/lib...container.aspx
request.CookieContainer = New CookieContainer()

Dim response As HttpWebResponse = CType(request.GetResponse(),
HttpWebResponse)

' Print the properties of each cookie.
Dim cook As Cookie
For Each cook In response.Cookies
Console.WriteLine("Cookie:")
Console.WriteLine("{0} = {1}", cook.Name, cook.Value)
Console.WriteLine("Domain: {0}", cook.Domain)
Console.WriteLine("Path: {0}", cook.Path)
Console.WriteLine("Port: {0}", cook.Port)
Console.WriteLine("Secure: {0}", cook.Secure)

Console.WriteLine("When issued: {0}", cook.TimeStamp)
Console.WriteLine("Expires: {0} (expired? {1})", cook.Expires,
cook.Expired)
Console.WriteLine("Don't save: {0}", cook.Discard)
Console.WriteLine("Comment: {0}", cook.Comment)
Console.WriteLine("Uri for comments: {0}", cook.CommentUri)
Console.WriteLine("Version: RFC {0}", IIf(cook.Version = 1,
"2109", "2965"))

' Show the string representation of the cookie.
Console.WriteLine("String: {0}", cook.ToString())
Next cook

"Paul" <Pa**@discussions.microsoft.comwrote in message
news:97**********************************@microsof t.com...
Does anyone know how to loop through the CookieContainer to see each
individual cookie item?

Or is the CookieContainer just one variable with all the cookies in it?

TIA.

Nov 7 '07 #2
Thanks for you assistance with this but the example below shows how to look
through the Cookies collection of a Response object.

I am trying to figure out how to loop through - or display - the contents of
the CookieContainer. This is different than the Response object.

"IfThenElse" wrote:
From :
http://msdn2.microsoft.com/en-us/lib...container.aspx
request.CookieContainer = New CookieContainer()

Dim response As HttpWebResponse = CType(request.GetResponse(),
HttpWebResponse)

' Print the properties of each cookie.
Dim cook As Cookie
For Each cook In response.Cookies
Console.WriteLine("Cookie:")
Console.WriteLine("{0} = {1}", cook.Name, cook.Value)
Console.WriteLine("Domain: {0}", cook.Domain)
Console.WriteLine("Path: {0}", cook.Path)
Console.WriteLine("Port: {0}", cook.Port)
Console.WriteLine("Secure: {0}", cook.Secure)

Console.WriteLine("When issued: {0}", cook.TimeStamp)
Console.WriteLine("Expires: {0} (expired? {1})", cook.Expires,
cook.Expired)
Console.WriteLine("Don't save: {0}", cook.Discard)
Console.WriteLine("Comment: {0}", cook.Comment)
Console.WriteLine("Uri for comments: {0}", cook.CommentUri)
Console.WriteLine("Version: RFC {0}", IIf(cook.Version = 1,
"2109", "2965"))

' Show the string representation of the cookie.
Console.WriteLine("String: {0}", cook.ToString())
Next cook

"Paul" <Pa**@discussions.microsoft.comwrote in message
news:97**********************************@microsof t.com...
Does anyone know how to loop through the CookieContainer to see each
individual cookie item?

Or is the CookieContainer just one variable with all the cookies in it?

TIA.


Nov 7 '07 #3
Not sure if this helps???

For Each cook In MyHttpWebRequest.CookieContainer.GetCookies(new
Uri("MyURIString"))
.... blah blah...

Next
"Paul" <Pa**@discussions.microsoft.comwrote in message
news:DF**********************************@microsof t.com...
Thanks for you assistance with this but the example below shows how to
look
through the Cookies collection of a Response object.

I am trying to figure out how to loop through - or display - the contents
of
the CookieContainer. This is different than the Response object.

"IfThenElse" wrote:
> From :
http://msdn2.microsoft.com/en-us/lib...container.aspx
request.CookieContainer = New CookieContainer()

Dim response As HttpWebResponse = CType(request.GetResponse(),
HttpWebResponse)

' Print the properties of each cookie.
Dim cook As Cookie
For Each cook In response.Cookies
Console.WriteLine("Cookie:")
Console.WriteLine("{0} = {1}", cook.Name, cook.Value)
Console.WriteLine("Domain: {0}", cook.Domain)
Console.WriteLine("Path: {0}", cook.Path)
Console.WriteLine("Port: {0}", cook.Port)
Console.WriteLine("Secure: {0}", cook.Secure)

Console.WriteLine("When issued: {0}", cook.TimeStamp)
Console.WriteLine("Expires: {0} (expired? {1})",
cook.Expires,
cook.Expired)
Console.WriteLine("Don't save: {0}", cook.Discard)
Console.WriteLine("Comment: {0}", cook.Comment)
Console.WriteLine("Uri for comments: {0}", cook.CommentUri)
Console.WriteLine("Version: RFC {0}", IIf(cook.Version = 1,
"2109", "2965"))

' Show the string representation of the cookie.
Console.WriteLine("String: {0}", cook.ToString())
Next cook

"Paul" <Pa**@discussions.microsoft.comwrote in message
news:97**********************************@microso ft.com...
Does anyone know how to loop through the CookieContainer to see each
individual cookie item?

Or is the CookieContainer just one variable with all the cookies in it?

TIA.



Nov 7 '07 #4
Yes it does thank you.

"IfThenElse" wrote:
Not sure if this helps???

For Each cook In MyHttpWebRequest.CookieContainer.GetCookies(new
Uri("MyURIString"))
.... blah blah...

Next
"Paul" <Pa**@discussions.microsoft.comwrote in message
news:DF**********************************@microsof t.com...
Thanks for you assistance with this but the example below shows how to
look
through the Cookies collection of a Response object.

I am trying to figure out how to loop through - or display - the contents
of
the CookieContainer. This is different than the Response object.

"IfThenElse" wrote:
From :
http://msdn2.microsoft.com/en-us/lib...container.aspx
request.CookieContainer = New CookieContainer()

Dim response As HttpWebResponse = CType(request.GetResponse(),
HttpWebResponse)

' Print the properties of each cookie.
Dim cook As Cookie
For Each cook In response.Cookies
Console.WriteLine("Cookie:")
Console.WriteLine("{0} = {1}", cook.Name, cook.Value)
Console.WriteLine("Domain: {0}", cook.Domain)
Console.WriteLine("Path: {0}", cook.Path)
Console.WriteLine("Port: {0}", cook.Port)
Console.WriteLine("Secure: {0}", cook.Secure)

Console.WriteLine("When issued: {0}", cook.TimeStamp)
Console.WriteLine("Expires: {0} (expired? {1})",
cook.Expires,
cook.Expired)
Console.WriteLine("Don't save: {0}", cook.Discard)
Console.WriteLine("Comment: {0}", cook.Comment)
Console.WriteLine("Uri for comments: {0}", cook.CommentUri)
Console.WriteLine("Version: RFC {0}", IIf(cook.Version = 1,
"2109", "2965"))

' Show the string representation of the cookie.
Console.WriteLine("String: {0}", cook.ToString())
Next cook

"Paul" <Pa**@discussions.microsoft.comwrote in message
news:97**********************************@microsof t.com...
Does anyone know how to loop through the CookieContainer to see each
individual cookie item?

Or is the CookieContainer just one variable with all the cookies in it?

TIA.


Nov 7 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2751
by: Arne Schittenhelm | last post by:
Hello, I try to figure out if there is a way to read the local cookies with CookieContainer or another .net cookie class. If I use a filename as URI I get a System.UriFormatException or...
0
980
by: Noel Austin | last post by:
I've run into a problem working with the CookieContainer and was wondering if anyone else has noticed this. The CookieContainer reorders it's cookies. When you send it back to the server using...
1
3724
by: VEJIKYUULYCY | last post by:
Hi all, I'm trying to get a .Net client (C# console app) maintain a session with a Java-based web service (Axis), but it doesn't seem to work. (Of course, a Java client to the same service works...
1
4622
by: guyhey | last post by:
I am accessing a site that passes the following headers: Set-Cookie: ASP.NET_SessionId=pwdciy45i0c5me45urxjfoi0; path=/ Set-Cookie: LastSessID=pwdciy45i0c5me45urxjfoi0; expires=Tue, 01-Mar-2016...
4
5145
by: macro | last post by:
when I use HttpWebRequest with CookieContainer object that handles cookies, if I have this cookie header in a response: Set-Cookie: CookieName=; path=/;expires=01-Jan-1999 00:00:00 GMT the...
4
1993
by: macro | last post by:
when I use HttpWebRequest with CookieContainer object that handles cookies, i make more than one request and needs to handle cookies being added and removed between requests, just like a regular...
1
8169
by: Mr Flibble | last post by:
OK I logon to a web site and I manage to get an SMSESSION cookie that I then store in a variable called _session (a class scoping variable). I do this by calling a logon URL and setting a cookie...
5
35252
by: rlueneberg | last post by:
I am totally confused. Can someone please illuminate what is going on under the hood in this piece of code from John Lewis. My main confusion is how the cookieContainer can be passed to the...
4
10106
by: =?Utf-8?B?UGF1bA==?= | last post by:
I have a CookieContainer full of Cookies. I want to loop through the CookieContainer to display the cookies? How can I do this. I know how to loop through a CookieCollection and display the...
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7273
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7451
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5572
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5000
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4667
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3150
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
374
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.