Is it possible to share forms authentication *only* across sub-sub domains?

跟風遠走 提交于 2019-12-22 10:31:59

问题


I know I can share forms authentication across 2 subdomains sub1.domain.com, sub2.domain.com by using the following Web.config setting:

<authentication mode="Forms">
    <forms domain="domain.com" />
</authentication>

However, I have 2 "sub-sub" domains (not sure if there's a better term for that) a.sub.domain.com, and b.sub.domain.com. Now I want to share the forms authentication cookies only on sub.domain.com, and not my entire domain.com. Is it possible to do this?

I tried the obvious solution below but it doesn't work, and always redirects back to the login page:

<authentication mode="Forms">
    <forms domain="sub.domain.com" />
</authentication>

Is it possible to share the cookies only across domains that end with sub.domain.com?


回答1:


So it turned out that my old cookies in my browser were somehow conflicting with the new setting.

After clearing all domain.com cookies, the solution I was trying now works, in case anyone faces a similar situation.

Also note I believe it's preferable to prepend a . to the domain:

<authentication mode="Forms">
    <forms domain=".sub.domain.com" />
</authentication>


来源:https://stackoverflow.com/questions/18462755/is-it-possible-to-share-forms-authentication-only-across-sub-sub-domains

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!