Cookie is not getting deleted in IE 8.

Posted by Ajit on Stack Overflow See other posts from Stack Overflow or by Ajit
Published on 2010-03-31T13:12:58Z Indexed on 2010/03/31 13:13 UTC
Read the original article Hit count: 258

Filed under:
|

Hello guys,

I'm trying to delete a cookie but somehow it is not getting deleted in IE 8

This is the code i'm using

HttpCookie userCookie = Request.Cookies[cookieName];

            if (userCookie != null)
            {
                userCookie.Expires = DateTime.Now.AddDays(-1);
                if (!string.IsNullOrEmpty(cookieDomain))
                    userCookie.Domain = cookieDomain;
                Response.Cookies.Add(userCookie);
            }            

It is working fine in firfox and chrome .

Suppose the name of the cookie is testcookie. We created this cookie from xyz.com and we set the domain of the cookie as ".xyz.com". Now we are deleting or expiring this cookie from subdomain.xyz.com. We are deleting the cookie with the code we have mentioned above.

© Stack Overflow or respective owner

Related posts about cookies

Related posts about c#