Subdomain cookie sharing in nginx

Tag: security , cookies , nginx , subdomains , gunicorn Author: zhlp_0718 Date: 2012-07-16

I have server, running some number of sites. For example: All sites are routed via nginx to unix domain-sockets. Each of sites is gunicorn instance.

Can applications from subdomains read/write cookie data from or from other subdomains? If yes, how to disable it?

Best Answer

Sure, you can use separate cookies for the subdomain. The Cookie standards allow you to set a domain, which will be the only domain that browsers will send the cookie back to. You can set "" as the domain, and browsers will only send cookies from that domain back to that domain.

From my reading of RFC 2965 for cookies, "" cannot set a cookie for "", only "".

I think the bottom line is to be sure that you are are using the "domain" property of cookies to set cookies for the subdomain, and not just "", which all subdomains could read and write to.


I'm sorry, question was about cookie data. Edited.