Cookies across subdomains and hosts

后端 未结 5 2229
被撕碎了的回忆
被撕碎了的回忆 2021-02-19 01:05

In the application I\'m writing using a combination of development environments and languages, I have need of accessing a cookie from two different subdomains, each on a separat

5条回答
  •  鱼传尺愫
    2021-02-19 01:44

    Cookies set in domain

    '.aaa.sub.domain.com'

    will collide with identically named cookies set in domain

    '.sub.domain.com'

    and '.some.stupidly.obscure.multi.sub.domain.com'

    That means (and this took some time to wade thru) if you're going to use the same-named cookie across multiple domains, you must set it once (and once only) in the main/base domain, in this case '.domain.com'; otherwise, the resulting cookie will be indeterminantly and randomly returned arrived at, sometimes the cookie 'jasper' set in .a.sub.domain.com, sometimes the cookie 'jasper' set in .sub.domain.com, sometimes the cookie 'jasper' set in .b.c.d.domain.com, sometimes the cookie 'jasper' set in '.sub.domain.com' and sometimes the cookie 'jasper' set in '.domain.com'

提交回复
热议问题