question:
The website has three different second-level domain names: bbs.xxx.com / main.xxx.com / pay.xxx.com. To achieve login at any first- and second-level domain name, all other second-level domain names can be logged in.
Solution:
Set the domain attribute of the cookie.
Detailed introduction:
Just set the domain of the cookie that saves the user's login information to the same one.
usercookie.Domain=".xxx.com"; Note that a "." must be added before the domain name.
This setting is required both when logging in and logging out.
A more common approach is to use a class specifically responsible for user login to manage these transactions. In this way, other login pages only need to call this class, and everything will be covered.
And if you use asp.net 2.0 and forms authentication, there is an easier way to complete this setup.
Support for domains has been added to web.config, just follow the following settings:
<authentication mode="Forms">
<forms loginUrl="Login.aspx" domain=".xxx.com" name=".AutoLinkEduSiteCookie"/>
</authentication>
domain: optional attribute.
Specifies an optional domain to be set in the outgoing Forms authentication cookie. This setting takes precedence over the domain used in the httpCookies element.
This property is new in .NET Framework version 2.0. The default value is the empty string ("").
Note that no matter which method is used, the name of the cookie must be the same.