Cookies and subdomains

前端 未结 3 502
温柔的废话
温柔的废话 2020-11-30 09:43

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 implementin

相关标签:
3条回答
  • 2020-11-30 10:25

    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">
    
    0 讨论(0)
  • 2020-11-30 10:35

    Yes, you can. Use:

    Response.Cookies("UID").Domain = ".myserver.com"
    
    0 讨论(0)
  • 2020-11-30 10:39

    Yes, but beware don't set same-named cookies in various subdomains, as the resulting cookie appears to be random; instead, set one cookie in the .maindomain.com only (not in any .sub.domain.com)

    0 讨论(0)
提交回复
热议问题