views:

560

answers:

2

I am using ASP.NET and C#.

I must read a cookie called "TheCookie".............

TheCookie have about 3 values in them. Cookie1, Cookie2 and Cookie3.

How would i get the value in code to read Cookie2's value inside "TheCookie"?

This is how i would read when a cookie only have 1 value, but i dont know what to do when there are multiple vales in the cookie.......... Code for VB.NET

Dim userCookie As HttpCookie
userCookie = Request.Cookies("UserEmail")

Thanks in advanced!

+3  A: 

You set them via

(C#)

Response.Cookies["TheCookie"]["Cookie1"] = "Hello World";

(VB)

Response.Cookies("TheCookie")("Cookie1") = "Hello World"

and read them like so

(C#)

string myValue = Request.Cookies["TheCookie"]["Cookie1"];

(VB)

Dim myValue As String
myValue = Request.Cookies("TheCookie")("Cookie1")
blowdart
+1  A: 
Request.Cookies.Get("TheCookie").Values.Get("Cookie1")
Request.Cookies.Get("TheCookie").Values.Get("Cookie2")
Request.Cookies.Get("TheCookie").Values.Get("Cookie3")

C# syntax, sorry!

Pawel Krakowiak