Delete cookie error in IE?

I am trying to delete some cookie that javascript set, it works well in Firefox and Chrome, but not in IE, it deletes the cookie value in IE, but not the file, so when I load a page that uses cookie, it loads some junk instead of nothing after removal.

I set the cookie as follows

var exdate = new Date(); exdate.setDate(exdate.getDate() + 1); var c_value = escape(data.d) + "; expires=" + exdate.toUTCString(); document.cookie = "user" + "=" + data.d; 

and delete it like this:

 document.cookie = 'user=; expires=Thu, 01-Jan-70 00:00:01 GMT;'; 

where is my problem


I also have code in C # for ASP.Net to delete a cookie, but it doesn’t work in any of the web browsers (it works for a cookie that was set by C #, but not with Javascript), where there is a problem with this code ?

 FormsAuthentication.SignOut(); Response.Cookies["user"].Expires = DateTime.Now.AddDays(-1); Session.Clear(); Response.Cookies.Clear(); 
+4
source share
2 answers

you must send the cookie to the response stream, otherwise your modification will never be passed to the browser.

I usually use this code to exit the system:

 FormsAuthentication.SignOut(); CurrentContext.Session.Abandon(); HttpCookie c = CurrentContext.Request.Cookies[FormsAuthentication.FormsCookieName]; if (c != null) { c.Expires = DateTime.Now.AddDays(-1); CurrentContext.Response.Cookies.Add(c); } 
0
source

When creating a cookie Try turning on the domain name

Response.Cookies ("abc"). Domain = ".xyz.com"

and when deleting

 Response.Cookies("uid").Value = Nothing Response.Cookies("abc").Expires DateTime.Now.AddDays(-1) Response.Cookies("abc").Domain = ".xyz.com" 

and check your cookies using the following tools

http://www.nirsoft.net/utils/iecookies.html

0
source

Source: https://habr.com/ru/post/1381406/


All Articles