The example of this article describes the PHP Web system multiple domain login failed to solve the problem, to share with you for your reference. The specific analysis is as follows:
The following is a simple logical structure that requires specific processing for a formal system.
Here is the need to note: Encryption and decryption must be done security verification. But this method is not perfect enough, two sites must have the same level of domain name, and this is completely based on cookies, the security is not high enough
function login ()
{
$info = Callloginserver ()///Access Login Server
if (!empty ($info)) //Login succeeded
}
// User is not logged in, then log in to the system and invoke login Server interface
function login () ///Normal login {....
//
Verify the legality of the user
$_session[' uid ' = $ user_id;
Setcookie (' sign ', encrypt ($pass 9), ', '/', ' the.com ');
Check to see if the user is logged on in the login system first
Funtion sign ()
{
$sign = $_cookie[' sign '];
if (!empty ($sign))
{
$sign = decrypt ($sign);
...///login succeeded
}
}.
User is not logged in, log in and invoke Login server interface in this system
function loging ()//This system login
{
...//Login succeeded
callseverlogin ();//notify User login
}
All sites share a login system; When a user succeeds in one of the sites, the system invokes the login interface of the other site, completes the user's login at the other site, sets the appropriate login information, or only saves the user's logon information on the system when the user logs on to the other site. The system interface must be requested to obtain information about whether the user is logged on. The disadvantage of the previous approach is that those sites need to save user status regardless of the user's use of other sites, and the latter method shifts all the pressure to the login system. If you want to achieve the user to exit the unified operation, it will require the site to call the login system exit interface, and then log on to the system interface calls other sites exit interface, or set a tag, if the tag does not exist then the user exits, as long as the mark is clear, Other sites found that the indicator does not exist to know that the user has exited the system.
This type of processing requires the login system and between the site to specify the logon interface, and logout interface. Through these interfaces, each site can easily handle the user login or exit.
I hope this article will help you with your PHP program design.