C# and cookies
Posted on 2004-08-16
Hello, new to .Net. I'm trying to just check for a cookie and use or store information based off whether or not an existing cookie already exists. The problem I'm having is that my application will not recognize an existing cookie, and each time I build to test my app it just creates a new one. Also, I can not find this new cookie anywhere on my machine, especially where I would expect to find cookies. I've checked everywhere.
I've restarted IIS on my machine as well as rebooted just in case something was up there. Can't put my finger on exactly what's happening, although somehow I suspect that the cookie information is only getting set within the application, and not on my local box to see the next time around??
Here is the simple page in question. What I'm doing here is this class represents a component that will be inherited on subsequent pages for easy code reuse defining global variables and session information. I would expect that after I've run and tested this the first time, on the second time around it would tell me that the cookie is not null, and it does not and continues as if it were not there.
public class BaseCode : System.Web.UI.Page
override protected void OnInit(EventArgs e)
if (Request.Cookies["name"] != null)
Response.Write("cookie is not null");
Response.Write("cookie is null");
Response.Cookies["name"].Value = "this is my name";
Response.Write("<br>cookie value: " + Request.Cookies["name"].Value);
thanks in advance!!