PHP Web system multi-domain login failed to solve the problem, phpweb_php tutorial

Source: Internet
Author: User
Tags php programming setcookie domain name registration

PHP to appear in the Web system multi-domain login failure solution, Phpweb


This article describes the PHP Web system multi-domain login failure to solve the problem, share for everyone to reference. The specific analysis is as follows:

The following is a simple logical structure, for the formal system needs to do specific processing.

It should be noted here: encryption and decryption must be done to verify the security. But this method is not perfect, two sites must have the same domain name, and this completely cookie-based approach, security is not high enough

function login () {  $info = Callloginserver ();//Access Login Server  if (!empty ($info))  //Login successful}//user not logged in, Then log in to the system and invoke the 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 that the user is logged on to the system first

Funtion sign () {$sign = $_cookie[' sign '), if (!empty ($sign)) {   $sign = decrypt ($sign);  ....///Login Successful}}

User is not logged in, log in to the system and invoke the login server interface

function loging ()//System Login {  ...//Login successful Callseverlogin ();//notify User login}

All sites share a login system; When a user logs on successfully in one of the sites, the system calls the login interface of the other site, completes the user's login at another site, and sets the appropriate login information, or when the user logs on, the user login information is saved only on the system, and when the user logs on to another 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, regardless of whether users use other sites, those sites need to save the user state, the latter way, all the pressure is transferred to the login system. If you want to implement the user exit of the unified operation, you need to call the site to log on the system's exit interface, and then log on to the system interface to call the other site exit interface, or set a tag, if the tag does not exist, indicating that the user exits, at this point, just empty the mark, Other sites find that the flag does not exist knowing that the user has exited the system.

This approach requires a login interface between the login system and the site, and the logout interface. Through these interfaces, each site can easily handle user login or exit.

I hope this article is helpful to everyone's PHP programming.


PHP How to implement User level two domain name simultaneous login problem

You should look carefully at the PHP handbook and say it clearly.
BOOL Setcookie (String $name [, String $value [, int $expire [, String $path [, String $domain [, bool $secure [, BOOL $h Ttponly]] []

With the Setcookie function, an optional argument is a string $domain this is the role domain name, for example, you want to set www.aa.com and bbs.aa.com also valid for this parameter is ". AA.com" Remember the previous one.

What is the PHP-based domain name registration system, the virtual host system to be high security, pay can also

PHP Domain name and virtual host more than the general foreign, such as Whmcs, AWBs, cpanel also calculate it.
Domestic only Prima, but this software price is higher, also a long time did not update. Domestic ASP-based domain name host system is more.
Xu Fei [authoritative expert]

http://www.bkjia.com/PHPjc/887346.html www.bkjia.com true http://www.bkjia.com/PHPjc/887346.html techarticle PHP appeared in the Web system multi-domain login failure solution, Phpweb This article describes the PHP Web system multi-domain login failure to solve the problem, share for everyone to reference. Specific points ...

  • 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.