0

I've got an problem with Cookie. That's the code:

NameValueCollection ncook = new NameValueCollection();
ncook = HttpContext.Current.Request.Cookies["history"].Values - in that line

What is in my cookie:

item_0=nonpacket-program.aspx?id=360ANDcourse=1044ANDcenter=238ANDfeeding=ANDinhabitation=

That's what I expect to recieve from the line showen before. And here it is what I actualy recieve:

item_0=nonpacket-program.aspx%3fid%3d360ANDcourse%3d1044ANDcenter%3d238ANDfeeding%3dANDinhabitation%3d&item_0=nonpacket-program.aspx%3fid%3d360ANDcourse%3d1044ANDcenter%3d238ANDfeeding%3dANDinhabitation%3d

How you can see the value is doubled. And that's the problem.... What am I doing wrong?

  • You're showing us the code where you *retrieve* the cookie, but if you're getting doubled-up results the problem likely exists in the code where you *set* the cookie. – Chris Jul 17 '13 at 15:48
  • I showed you what lies in the cookie and there is nothing more but other items (item_1,2,3....) So I believe I set cookie right but if you still believe that there might be something wrong I can send it to you. – Dima Mitikov Jul 18 '13 at 06:26

1 Answers1

0

First thought is that you are assigning ncook the value of an existing cookie, and then a postback happens, and the "history" cookie now has two entries in its values. the "history" cookie is a history, so for each postpack, I'm betting the history cookie grows, and thus, ncook will grow as well.

  • 1
    Hi. I founded what you said. In one class I request cookie to set it up and I need to check for the same values first and in other class I call it again to create a list on an web page... Is that possible to have any trick here? – Dima Mitikov Jul 18 '13 at 07:14
  • 1
    Problem solved. Now I call cookie one time and keep them in session – Dima Mitikov Jul 18 '13 at 08:25