- using cookies

sirbounty used Ask the Experts™
On page load, I'm going to grab details of a user's assignments, based on the user coming to the site.
I'm going to populate a checkedlistbox with just a reference ID and associated title.

However, when they click on an item, I want to show the further details based upon that reference ID.

Originally I was going to create a list, and add reference to all of the details there, but I believe that maybe cookies might serve me better here - although I'm not very familiar how to use them properly.

Can someone provide some guidance?
I'd love to have some ability to search a cached table based on the ID selected, and retrieve the details that way, rather than making another call to the databse.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Using cookies is pretty simple.

Setting cookies
Response.Cookies["yourcookiename"]["field1"] = "mydata1";
Response.Cookies["yourcookienames"]["field2"] = "mydata2";
 Response.Cookies["yourcookiename"].Expires = DateTime.Now.AddMinutes(15); //expire in 15 minutes.

Open in new window

Reading cookies.

Open in new window

You can also make use of session, but if you will use multiple servers or even more than one worker process in IIS then this method is a no good.
Session.Add("yourcookiename", "yourdata");
// and read with

Open in new window

Top Expert 2007


Thanks much

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial