0

I have two or three apps that i put into Application pool, so every site are differentiate by using slash /CONSUMER/, /CONSUMER2/, /LOGIN/ , and /MNT, i could only login from CONSUMER, how could i remove cookies (i want to remove userInfo and loginSeassion), from another applications pools, because at the productions after i'm using CONSUMER, the next things the apps will be redirect is to LOGIN app, but at the LOGIN app the cookies are not removed,

enter image description here

i'm using aspx.net and c# for visual studio 2008, the only i could do are using this code,

            // Getting URL of the web
            string urlScheme = HttpContext.Current.Request.Url.Scheme;
            string urlAuthority = HttpContext.Current.Request.Url.Authority;

            // Creating a request to retrieve cookies
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urlScheme + "://" + urlAuthority);

            // Get the cookies collection
            HttpCookieCollection cookies = HttpContext.Current.Request.Cookies;

            // Remove cookies based on scheme and authority
            foreach (string cookieName in cookies.AllKeys)
            {
                HttpCookie cookie = cookies[cookieName];
                if (cookie.Domain == urlAuthority && (urlScheme == "http" || urlScheme == "https"))
                {
                    cookie.Expires = DateTime.Now.AddDays(-1);
                    HttpContext.Current.Response.Cookies.Add(cookie);
                }
            }
Appem
  • 295
  • 1
  • 3
  • 16
  • Set the [path](https://learn.microsoft.com/en-us/dotnet/api/system.web.httpcookie.path?view=netframework-4.8.1) to "/" so that they are visible cross-site. See also [this question](https://stackoverflow.com/questions/576535/cookie-path-and-its-accessibility-to-subfolder-pages) – John Wu Aug 23 '23 at 08:46

0 Answers0