Cookies 会话是否可以传输到指向同一CF实例的不同域?

Cookies 会话是否可以传输到指向同一CF实例的不同域?,cookies,coldfusion,Cookies,Coldfusion,假设localhost和localhost2都指向127.0.0.1 在//localhost/test/test.cfm(\wwwroot\test\test.cfm)中 在//localhost2/test/test2.cfm(\wwwroot\test\test2.cfm)中 我希望//localhost2/test/test2.cfm显示session.name=“HAHA”,但它会生成一个新会话,为什么?是因为我无法从localhost设置.localhost2 cookie吗

假设localhost和localhost2都指向127.0.0.1

在//localhost/test/test.cfm(\wwwroot\test\test.cfm)中


在//localhost2/test/test2.cfm(\wwwroot\test\test2.cfm)中


我希望//localhost2/test/test2.cfm显示session.name=“HAHA”,但它会生成一个新会话,为什么?是因为我无法从localhost设置.localhost2 cookie吗

谢谢

会话可以跨域,但cookie不能。(正如您所发现的,子域有点不同。)出于安全原因,abc.com无法访问xyz.com的cookies。然而,CF本身并不关心您使用的域名


因此,如果您有一个链接没有在URL中传递cfid和cftoken,那么会话将丢失。但是,如果您在链接中(或在cflocation中,等等)传递了id和令牌,会话仍然是活动的

我试过使用one.localhost和two.localhost,并将cfcookie domain=“.localhost”设置为有效:)
<cfset session.name="HAHA">
<cfcookie domain=".localhost2" name="CFID" value="#session.cfid#">
<cfcookie domain=".localhost2" name="CFTOKEN" value="#session.cftoken#">
<cflocation url="//localhost2/test/test2.cfm" addtoken="false">
<cfdump var="#session#">