Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cookies and subdomains

Tags:

Can a cookie be shared between two sites on the same top level domain? Say www.example.com and secure.example.com ? We are looking into implementing a cache for non-secure content, and need to segregate secure content to another domain. What parameters does the cookie need? I'm using asp.net

like image 694
pgb Avatar asked Sep 20 '08 15:09

pgb


2 Answers

Yes, you can. Use:

Response.Cookies("UID").Domain = ".myserver.com"
like image 123
Rich Bradshaw Avatar answered Sep 20 '22 02:09

Rich Bradshaw


The easiest way to apply a cookie domain that can be shared across subdomains is to put it in your web.config:

<forms cookieDomain="example.com">
like image 28
Jess Chadwick Avatar answered Sep 17 '22 02:09

Jess Chadwick