multiple cookies with same name, why?

E

evolve

in the trace information
i am getting the following:

userID 81
username nick.......
projID 1
ProjName Jupiter
inDus 4F2EA4.........
ASP.NET_SessionId 0vg5mca.....
ProjID 2
ProjName Vis
ProjID 6



as you can see there are multiple instances of the same thing
which is no use to me as I am trying to track what the user
is doing by storing certain attributes in cookies

here is a sample of how i am adding the cookies [c#]:
System.Web.HttpCookie ProjName = new System.Web.HttpCookie("ProjName");

ProjName.Value = DdlProjects.SelectedItem.Text;

ProjName.Expires = DateTime.Now.AddDays(30);

System.Web.HttpCookie ProjID = new System.Web.HttpCookie("ProjID");

ProjID.Value = DdlProjects.SelectedItem.Value;

ProjID.Expires = DateTime.Now.AddDays(30);

Response.Cookies.Add(ProjName);

Response.Cookies.Add(ProjID);


this would explain some of the problems i have been having but is there no
way to overwrite the contents
of an existing value?
 
E

evolve

its because the page is being called twice
not sure why this is happening either as the code that writes cookies is
wrapped in a !postback section

hmmm......
 
E

evolve

found out why:

the thing that was writing the cookies out was when the user selected
something from a drop down
however
when the page is originally loaded
the previously chosen value(if exists) is then selected

this appears to call the drop down selected index changed function (even
though the user isn't driving it)
so i just put a
if(page.ispostback)
around the inside of the function and now it works fine



evolve said:
its because the page is being called twice
not sure why this is happening either as the code that writes cookies is
wrapped in a !postback section

hmmm......


evolve said:
in the trace information
i am getting the following:

userID 81
username nick.......
projID 1
ProjName Jupiter
inDus 4F2EA4.........
ASP.NET_SessionId 0vg5mca.....
ProjID 2
ProjName Vis
ProjID 6



as you can see there are multiple instances of the same thing
which is no use to me as I am trying to track what the user
is doing by storing certain attributes in cookies

here is a sample of how i am adding the cookies [c#]:
System.Web.HttpCookie ProjName = new System.Web.HttpCookie("ProjName");

ProjName.Value = DdlProjects.SelectedItem.Text;

ProjName.Expires = DateTime.Now.AddDays(30);

System.Web.HttpCookie ProjID = new System.Web.HttpCookie("ProjID");

ProjID.Value = DdlProjects.SelectedItem.Value;

ProjID.Expires = DateTime.Now.AddDays(30);

Response.Cookies.Add(ProjName);

Response.Cookies.Add(ProjID);


this would explain some of the problems i have been having but is there no
way to overwrite the contents
of an existing value?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top