Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET cookies with multiple values - how to?

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 advance!

like image 751
Etienne Avatar asked Oct 14 '09 08:10

Etienne


1 Answers

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")
like image 74
blowdart Avatar answered Sep 24 '22 11:09

blowdart