A
Alan Draper via .NET 247
I have the following code, which should show "No Cookie Set" the first time you visit, and then show the last time you visited each consecutive time. Should be simple, right...
const string COOKIE_NAME = "TestCookie";
private void Page_Load(object sender, System.EventArgs e) {
HttpCookie cookie = Request.Cookies[COOKIE_NAME];
txtOut.InnerHtml = ( cookie == null ) ? "No Cookie Set" : cookie.Value;
cookie = new HttpCookie( COOKIE_NAME, DateTime.Now.ToString() );
Response.Cookies.Add( cookie );
}
... but it is only working when I view it on http://localhost. When I look at http://myserver.mydomain.com, I get "No Cookie Set" over and over. Anyone have any ideas?
Thanks -- Alan
P.S. I've tried changing the settings on my browser to allow all cookies. Didn't help.
const string COOKIE_NAME = "TestCookie";
private void Page_Load(object sender, System.EventArgs e) {
HttpCookie cookie = Request.Cookies[COOKIE_NAME];
txtOut.InnerHtml = ( cookie == null ) ? "No Cookie Set" : cookie.Value;
cookie = new HttpCookie( COOKIE_NAME, DateTime.Now.ToString() );
Response.Cookies.Add( cookie );
}
... but it is only working when I view it on http://localhost. When I look at http://myserver.mydomain.com, I get "No Cookie Set" over and over. Anyone have any ideas?
Thanks -- Alan
P.S. I've tried changing the settings on my browser to allow all cookies. Didn't help.