ASP.net - using cookies

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.
LVL 67
sirbountyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hilltopCommented:
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.
Request.Cookies["yourcookiename"]["field1"].ToString();
Request.Cookies["yourcookiename"]["field2"].ToString();

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
Session["yourcookiename"].ToString();

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sirbountyAuthor Commented:
Thanks much
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.