0

my Parent domain: aswajith.com My sub domain : Cookie.aswajith.com

I can successfully share cookie to my SubDomain using the below code:

      HttpCookie hc = new HttpCookie("UserInfo");
      hc.Domain = ".aswajith.com";
      HttpContext.Current.Response.Cookies.Add(hc);
      Label1.Text = HttpContext.Current.Request.Cookies["UserInfo"].Value;

But i cant share when i change my parent domain to "www.aswajith.com" instead of aswajith.com .

What is the reason ?

Aswajith
  • 9,117
  • 5
  • 16
  • 20

1 Answers1

0

.aswajith.com

This makes the cookie available to all subdomains of asawjith.com : www.asawjith.com, cookie.asawjith.com, ...

Now if you set it to .www.aswajith.com it wont be visible to other subdomains of aswajith.com nor the parent domain. This is by design but it can be availble to subdomains of www.aswajith.com.

For more information about domain in cookies :

Community
  • 1
  • 1
Guillaume
  • 12,824
  • 3
  • 40
  • 48