Solution to failure to log on with multiple domain names in the web system in php

Source: Internet
Author: User
This article describes how to solve the failure of logon to multiple domain names in the php web system. it is very useful for logon failures of sub-sites under the same top-level domain name, for more information about how to resolve the failure of logon to multiple domain names in the php System, see the example in this article. 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.

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.