PHP appears web system multi-domain Login failure solution _php Tips

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.