I need to set main domain(abc.dis.com) cookie in my sub domain(xyz.dis.com) in sitecore,please suggest. Please find the below code snippet,but it's not working.
Thanks in Advance
Sitecore Stack Exchange is a question and answer site for developers and end users of the Sitecore CMS and multichannel marketing software. It only takes a minute to sign up.Sign up to join this community
The multiple domains can only share cookies if the domain is explicitly set in the Set-Cookie header. Otherwise, if you specify the scope like you did "
abc.dis.com" the scope of the cookie will be restricted to the that host only.
For instance, if you sent the following header from abc.dis.com:
Then the cookie won't be sent for requests to
But if you use the following, it will be created for all the subdomains like xyz.dis.com, lmn.dis.com, abc.dis.com etc.
Set-Cookie: name=value; domain=dis.com
You cannot specify another subdomain (
abc.dis.com) from subdomain
What you can do is to assign a cookie to top level domain
dis.com and all the subdomains like
anything.dis.com will be able to access that cookie:
Set-Cookie: name=value; domain=.dis.com
So your code should be
cook.Domain = ".dis.com"
cook.Domain = "dis.com"
The first code supports old specification. Nowadays, in most of the browsers trailing dot is not necessary.
You can read more about cookies in Set-Cookie article