Php provides a solution for failure to log on to the web system with multiple domain names.
This article describes how to solve the failure of logon to multiple domain names in the php system. The specific analysis is as follows:
The following is a simple logical structure that requires specific processing for formal systems.
Note that security verification is required for encryption and decryption. However, this method is not perfect, and the two sites must have the same level 1 domain name. In addition, this method is completely cookie-based, and the security is not high enough.
Function login () {$ info = callloginserver (); // access the logon server if (! Empty ($ info) // login successful} // if the user has not logged on, log on to the system and call the login server interface function login () // normal login {....... // verify the validity of a user $ _ session ['uid'] = $ user_id; setcookie ('sign', encrypt ($ pass9), '', '/', 'the. com ');}
First, check whether the user is logged on to the system.
Funtion sign () {$ sign = $ _ cookie ['sign']; if (! Empty ($ sign) {$ sign = decrypt ($ sign); ...... // login successful }}
If the user does not log on, log on to the system and call the logon server interface.
Function loging () // log on to the system {... // callseverlogin (); // notify the user to log on}
All sites share a logon system. When a user successfully logs on to one of the sites, the system calls the logon interfaces of other sites to log on to other sites, at the same time, set the corresponding login information; or when a user logs on, only the user login information is saved in the system. When the user logs on to another site, the user must request this system interface, obtains the logon information of a user. The disadvantage of the previous method is that, no matter whether the user uses other sites, those sites need to save the user status. The latter method transfers all the pressure to the logon system. To achieve a unified user exit operation, the site needs to call the exit interface for logging on to the system, and then log on to the system interface to call the exit interface for other sites; or set a flag, if this tag does not exist, it indicates that the user exits. In this case, you only need to clear the tag. If other sites find that the tag does not exist, they will know that the user has exited the system.
This method requires specifying the logon interface and logout interface between the login System and the site. Through these interfaces, each site can easily process user logon or exit.
I hope this article will help you with PHP programming.
How can php achieve simultaneous login of user second-level domain names?
You should carefully read the instructions in the PHP manual.
Bool setcookie (string $ name [, string $ value [, int $ expire [, string $ path [, string $ domain [, bool $ secure [, bool $ httponly]
You can use the SETCOOKIE function. An optional parameter is string $ domain, which is the domain name. For example, if you want to set www.aa.com and bbs.aa.com to be equally valid, this parameter is ".aa.com". Remember that there is a previous one.
What is a PHP-based domain name registration system? virtual host systems require high security and pay-as-you-go
PHP domain names and virtual hosts are generally more foreign, such as whmcs, awbs, and cpanel.
There is only prima in China, but this software is expensive and has not been updated for a long time. There are many asp-Based Domain Name host systems in China.
Xu Fei [authoritative expert]