ASP.NET MVC - cross sub domain authentication/membership

前端 未结 3 1584
醉酒成梦
醉酒成梦 2021-02-01 09:41

Hit a roadblock while implementing a sub domain based language switcher (en.domain.com loads English, jp.domain.com loads Japanese).

How do I get a single member

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-01 10:39

    Your problem is how browsers sends cookie during request.

    Cookie is generally tied to a single domain, this is for security reasons and performance. For example, user don't want to send cookie for your domain to any other domain, because your cookie may contain sensitive information.

    Browser do differentiate between cookies set with en.domain.com and jp.domain.com. They do not allow cookies from one domain goes to the other because they are not on a parent domain.

    The solution to your problem would be to take over the control of generating cookies. I haven't played much with ASP.NET MVC, but I'm sure it can be done not through the HTML but through a property or something. This is a very common scenario. You should set the cookies domain to "domain.com" for your production boxes, that is correct. If you're working on a local box, you should set the cookies domain to "".

提交回复
热议问题