Click here to Skip to main content
11,495,371 members (64,520 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET
Dear Sir/Ma'am

I am using with VB as default language and using sql server as backend .
I want to store multiple values in a Single Cookie .
Please Help me regarding this.

Sir i have a form

id (textbox1)

(Button 1)

Sir I want that i put the id as 1 in textbox1 and click on button then value of text box add in the cookie.

At this time in the cookie we have value

And when again i put the id as 2 in text box1 and click on the button then 2 also add in the cookie.

Now When i see the value of cookie then it must shows the values as

Please Help me to do this task
Posted 14-Feb-13 18:00pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1


Use of cookies:

////////////SET THE COOKIE//////////////

Response.Cookies["test"].Value = UserName.Text ;
Response.Cookies["test"].Expires = DateTime.Now.AddYears(30);
where test is the cookie name
and the username.text is the textbox that will be used to define the cookies information
in order to delete a cookie use this
Response.Cookies["test"].Expires = DateTime.Now.AddYears(-30);
in order to check whether the cookie is found or not and retrieve the cookies information use this
/////////check to see if cookie presented//////////

if (Request.Cookies["test"] == null)
TextBox2.Text = "No cookie found";
TextBox2 .Text = Request.Cookies["test"].Value;
/////////END check to see if cookie presented//////////

For multiple values refer the following links:

Storing multiple values in cookies
ASP.NET cookies with multiple values - how to?

Hope this will hep you.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Basics of Cookies in ASP.NET[^] should help you get started with the basics.
How to: Write a Cookie[^] is another good basic link.

Beginner's Guide to ASP.NET Cookies[^] could be useful too.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Dnyaneshwar@Pune 692
1 CHill60 318
2 Sascha Lefèvre 275
3 Sergey Alexandrovich Kryukov 255
4 Nakul Chaudhari 236
0 Sergey Alexandrovich Kryukov 10,307
1 OriginalGriff 8,821
2 Sascha Lefèvre 3,889
3 Maciej Los 3,412
4 Richard Deeming 2,560

Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 14 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100