0

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.

enter image description here

Thanks in Advance

1

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:

Set-Cookie: name=value

Then the cookie won't be sent for requests to xyz.dis.com.

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
0

You cannot specify another subdomain (abc.dis.com) from subdomain xyz.dis.com.

What you can do is to assign a cookie to top level domain dis.com and all the subdomains like abc.dis.com, xyz.dis.com or 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"

or

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.