开发者

Cookie is not getting deleted in IE 8

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);
            }       开发者_C百科     

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.


Check your cookies. You may have two cookies called "testcookie" or whatever. This has happened to me before and caused a lot of pain. You can check quickly by typing javascript:alert(document.cookie) into the address bar.

If you have got duplicate cookies delete all your cookies and start testing again. I.e. setting your testcookie, then on another request try expiring it again how you were before.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜