bir alt alandan oluşturulan bir çerez Erişme:Verilen başka bir alt alana
Domain 1: subdomain1.mydomain.com
Domain 2: subdomain2.mydomain.com
Ben aşağıdaki kodu kullanarak ve "Domain 2" konulu çerez erişmeye çalışıyor "Domain 1" bir çerez oluşturmak.
Sorunum, "Etki Alanı 2" çerezini tanımak istemiyor. Ne verir? Problemin .Domain özelliği ile olduğunu anladım, ama daha önce bir dönem koydum, o yüzden neyi özlüyorum?
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;
}
Düşünceler?