Cookie rewrite issues
The client has a website at a.url.com. The client creates a cookie with the host as ".url.com" and the path as "/". The client redirects us to b.url.com. The client has an encoding issue that requires us to delete the cookie (long story).
The following code doesn't time-out everything in our test or production environment, but it works fine locally.
if (Request.Cookies["cookie"] != null)
{
HttpCookie myCookie = new HttpCookie("cookie");
myCookie.Expires = DateTime.Now.AddDays(-1d);
Response.Cookies.Add(myCookie);
}
Any ideas?
source to share
We found it out. We needed to add one line of code to manually configure the domain. Makes sense now.
if (Request.Cookies["cookie"] != null)
{
HttpCookie myCookie = new HttpCookie("cookie");
myCookie.Domain = ".url.com";
myCookie.Expires = DateTime.Now.AddDays(-1d);
Response.Cookies.Add(myCookie);
}
source to share
Here's a hack. I'm just posting this in case you find out that you can't do what you want due to some security issue, preventing you from resolving the issue on the second site.
You can send a request to the first site to clear the cookie with a redirect and get the site back. As I said, this is very hacky (or I suppose marketing would call it cross-site collaborative defense).
Hopefully there will be a better approach, but at least you have an alternative if others don't show up.
source to share