How do I provide the same login function for two projects (under two servers respectively? Thoughts

Source: Internet
Author: User
Tags to domain
How can we provide the same login function for two projects (two servers respectively? Project a: DEPLOY project B on 192.168.0.1: deploy Project c on 192.168.0.2. the login function is required: project a and Project B can only be accessed after logging on to Project c. I am going to save the login status to the Cookie, but a and B are in two different servers (two servers respectively). how can I provide them with the same login function? Thoughts
Project a: deployed on 192.168.0.1
Project B: deployed on 192.168.0.2

Now we need to build a project c, and implement the login function: Project a and Project B must be logged on through Project c before they can be accessed.

I am going to save the login status to the Cookie, but a and B are on two different servers. how do I transmit this session (Cookie?
Thank you for your consideration!

------ Solution --------------------
If you still have no answers after one day, I will answer them.
------ Solution --------------------
The session is written in a table or maintained in the memory cache only in one place.
------ Solution --------------------
For a second-level domain name, set the cookie to the root domain name.
The sessionid can be followed by the url for verification for different domain names.
When a session is written to a table, the header information and IP address are obtained for encryption. when the domain name is directly entered, this information is obtained for verification.
Sprintf ('% 08x', crc32 (! Empty ($ _ SERVER ['http _ USER_AGENT '])? $ _ SERVER ['http _ USER_AGENT ']. ROOT_PATH. $ ip. $ session_id: ROOT_PATH. $ ip. $ session_id ));

The moderator may have a better solution
------ Solution --------------------
You can study single sign-on.
Our idea is to store the PHP Session data in a centralized manner. in this way, for PHP running on different servers, there is only one common Session database, the Session data generated by A user's logon to server A can be shared on server B, server C, server D, and other servers, thus avoiding multiple logins. However, because PHP sessions require cookies, and cookies are related to domain names, each server using this scheme needs to have the same domain name (at least the same second-level domain name ), for example:
1. the domain names of all servers are www.whybsd.com, which can be implemented through DNS round robin. in this case, set the Cookie domain name in PHP to www.whybsd.com;
2. all server domain names are at the end of .whybsd.com, such as a.whybsd.com and B .whybsd.com. at this time, set the Cookie domain name to .whybsd.com in PHP to share the Cookie.
------ Solution --------------------
CAS
------ Solution --------------------
Http://www.phpweblog.net/linxiaobo/archive/2009/04/15/6419.html
This is a common method. I can search for the address at will. a string after P3P cannot be remembered. you can check it out. A little bit, as long as the P3P settings are correct, certainly. This solution solves the cross-origin cookie problem.

Pay attention to the corresponding locations of the two domain names .. If you do not add P3P, IE, or Safari, it will not work. this is probably a third-party cookie?


In addition, you can also use iframe to [this does not have the concept of Cross-Origin]. different domain parent-child frameworks can pass values through url anchor ...... Expand your mind

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.