multiple cookies with same name, why?

  • Thread starter Thread starter evolve
  • Start date Start date
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?
 
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......
 
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?
 
Back
Top