I'm trying to do a check to see if the client browser has cookies
enabled. But my code below always gives me the value for acceptsCookies
= true, whether the machine has cookies enabled or not.
Can anybody help me out with this?
private void Page_Load(objec t sender, System.EventArg s e)
{
if (!(Page.IsPostB ack))
{
//check browser accepts cookies
HttpCookie checkCookies = new HttpCookie("che ckCookies");
checkCookies.Va lues["userName"] = "mike";
Response.Cookie s.Add(checkCook ies);
bool acceptsCookies = false;
if (Request.Cookie s["checkCooki es"].Values["userName"] == null)
{
acceptsCookies = false;
}
else
{
acceptsCookies = true;
//Delete test cookie
Response.Cookie s["checkCooki es"].Expires =
DateTime.Now.Ad dDays(-1);
}
lblInfo.Text = acceptsCookies ? "Accepts cookies" : "Doesn't accept
cookies";
}
}
Cheers,
Mike
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!