Cookies with Multiple Values in ASP.NET

Filed in ASP.NET, Web AppTags: , ,

Recently we discussed various facts about a Cookie. Today we will see that how a single cookie can store multiple values. First we will create a Cookie then we will store multiple values in the same Cookie. Also the important thing is to retrieve the all values of that cookies. Whether you can retrieve the values in the same variable of multiple variables.

Creating Cookie with Multiple Values:

Response.Cookies["empCookie"]["name"]= txtName.Text;
Response.Cookies["empCookie"]["age"]= txtAge.Text;
Response.Cookies["empCookie"]["Location"]= txtLocation.Text;

Retrieving multiple Cookies Value in single Variable:

We are going to Fetch the value in a single variable with comma(,) seperated value.

 string empdetails;
 empdetails = Request.Cookies["empCookie"]["name"]+","+Request.Cookies["empCookie"]["Age"]+","+Request.Cookies["empCookies"]["Location"];

Author Bio : This is Rajendra, A blogger running with a tech blog Daily Tech Updates .

Suggested Entry:
Cookies in ASP.NET
passing Multiple Values in QueryString

Sourabh Sharma (150 Posts)



No Responses to “Cookies with Multiple Values in ASP.NET”



Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>