K
Kevin Blount
I've created a quick set of test scripts, and I'm finding that cookies
don't work as I would expect(i.e. the same as they do in original ASP.
In original ASP I could set a cookie on one page, set another value to
that cookie on a second page, then read them both back on a third page,
but in .NET the second page overwrites the first.
here are my three .NET test pages:
setCookie1.aspx:
Response.Cookies["Communities"]["LoggedIn"] = "true";
Response.Cookies["Communities"]["member_id"] = "120";
Response.Cookies["Communities"].Expires = DateTime.Now.AddYears(30);
setCookie2.aspx:
Response.Cookies["Communities"]["banner"] = "1";
Response.Cookies["Communities"].Expires = DateTime.Now.AddYears(30);
viewCookies.aspx:
System.Text.StringBuilder output = new System.Text.StringBuilder();
HttpCookie aCookie;
for(int i=0; i<Request.Cookies.Count; i++)
{
aCookie = Request.Cookies;
output.Append("Cookie name = " + Server.HtmlEncode(aCookie.Name) +
"<br />");
output.Append("Cookie value = " + Server.HtmlEncode(aCookie.Value)
+ "<br /><br />");
}
Response.Write(output.ToString());
am I doing something wrong? In the real world here what I need to do:
I have a template that reads from the "Communities" cookie for the
value of the "LoggedIn" name, and if it's "true" does some database
work using the value of "member_id".
Later in this template I look for the value of "banner" and display a
graphic based on that value. I then increment the value and write it
back to the cookie.
It's at this point that "LoggedIn" and "member_id" are removed from the
cookie, and "banner" is added in their place. What I really would like
is for "banner" to be appended to the "Communities" cookie, and for all
three name-value pairs to be available, as I can do is original ASP.
Any ideas?
don't work as I would expect(i.e. the same as they do in original ASP.
In original ASP I could set a cookie on one page, set another value to
that cookie on a second page, then read them both back on a third page,
but in .NET the second page overwrites the first.
here are my three .NET test pages:
setCookie1.aspx:
Response.Cookies["Communities"]["LoggedIn"] = "true";
Response.Cookies["Communities"]["member_id"] = "120";
Response.Cookies["Communities"].Expires = DateTime.Now.AddYears(30);
setCookie2.aspx:
Response.Cookies["Communities"]["banner"] = "1";
Response.Cookies["Communities"].Expires = DateTime.Now.AddYears(30);
viewCookies.aspx:
System.Text.StringBuilder output = new System.Text.StringBuilder();
HttpCookie aCookie;
for(int i=0; i<Request.Cookies.Count; i++)
{
aCookie = Request.Cookies;
output.Append("Cookie name = " + Server.HtmlEncode(aCookie.Name) +
"<br />");
output.Append("Cookie value = " + Server.HtmlEncode(aCookie.Value)
+ "<br /><br />");
}
Response.Write(output.ToString());
am I doing something wrong? In the real world here what I need to do:
I have a template that reads from the "Communities" cookie for the
value of the "LoggedIn" name, and if it's "true" does some database
work using the value of "member_id".
Later in this template I look for the value of "banner" and display a
graphic based on that value. I then increment the value and write it
back to the cookie.
It's at this point that "LoggedIn" and "member_id" are removed from the
cookie, and "banner" is added in their place. What I really would like
is for "banner" to be appended to the "Communities" cookie, and for all
three name-value pairs to be available, as I can do is original ASP.
Any ideas?