Data:Accesso a un cookie creati su un sottodominio su un altro sottodominio
Domain 1: subdomain1.mydomain.com
Domain 2: subdomain2.mydomain.com
creo un cookie sul "Dominio 1" usando il codice seguente e cercando di accedere al cookie sul "Dominio 2".
Il mio problema è che "Dominio 2" non vuole riconoscere il cookie. Cosa dà? Immagino che il problema sia con la proprietà .Domain, ma ho inserito il periodo precedente, quindi cosa mi manca?
public void CreateCookie()
{
Boolean bNew = false;
HttpCookie oCookie = HttpContext.Current.Request.Cookies.Get("myData");
if (null == oCookie)
{
oCookie = new HttpCookie("myData");
bNew = true;
}
// Set the cookie value.
oCookie.Domain = ".mydomain.com";
oCookie.Secure = false;
oCookie["myid"] = "[email protected]";
oCookie.Expires = DateTime.Now.AddDays(7);
if (true == bNew)
HttpContext.Current.Response.Cookies.Add(oCookie);
else
HttpContext.Current.Response.Cookies.Set(oCookie);
}
public String GetCookie()
{
String myid = null;
HttpCookie oCookie = HttpContext.Current.Request.Cookies.Get("myData");
if (null != oCookie)
myid = HttpContext.Current.Server.HtmlEncode(oCookie["myid"]);
return myid;
}
Pensieri?