Skip to content

How to persist cookies across domain aliases with shared underlying Cloudfront distribution?

0

I have 2 hosted zones (one.com + www.one.com, and two.com + www.two.com) pointing to the same Cloudfront distribution blablablabla.cloudfront.net. The frontend lives in an S3 bucket.

Is there any way for these 4 domain aliases to share cookies, e.g. by setting them on the underlying Cloudfront domain blablablabla.cloudfront.net instead of one.com, www.one.com, two.com, or www.two.com?

I currently have the following aliases in the first hosted zone (and similar for the second), in addition to NS, SOA, and CNAME records:

one.com A Simple - Yes blablablabla.cloudfront.net. - - No -

www.one.com A Simple - Yes one.com. - - Yes -

asked 3 years ago391 views
1 Answer
0

This isn't possible due to the way that browsers work with regards to cookies. Take a look at the MDN documentation on the Set-Cookie header, especially the section on domain handling.

Though the CloudFront domain technically serves both aliases, the browser never sees that domain, only the aliases.

AWS
answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.