开发者

Cookie is not getting deleted in IE 8

开发者 https://www.devze.com 2022-12-25 01:07 出处:网络
I\'m trying to delete a cookie but somehow it is not getting deleted in IE 8 This is the code i\'m using

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

精彩评论

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

关注公众号