DEV Community

Belhassen Chelbi
Belhassen Chelbi

Posted on

Does a same-origin cookie work in a subdomain

Let's say the front-end is hosted in Netlify with domain.com and the backend in a VPS with api.domain.com.
For example: Django session authentication, can I get this to work like this?

Top comments (1)

Collapse
 
skaterdad profile image
Mike

Yes, that is possible. A period in front of the domain on that cookie headers is what tells browsers to send it on subdomains.

I'm not familiar with the way Django handles it, but hopefully this helps.
micropyramid.com/blog/how-to-maint...