Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the failure of multi-domain name login in web system when php appears?

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the relevant knowledge of "how to solve the failure of multi-domain name login in php web system". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

This paper gives an example of the solution to the failure of multi-domain name login in php web system, which is shared with you for your reference. The specific analysis is as follows:

The following is just a simple logical structure that needs to be dealt with specifically for a formal system.

It should be noted here that encryption and decryption must be verified by security. But this method is not perfect, two sites must have the same first-level domain name; in addition, this completely cookie-based approach is not secure enough

Function login () {$info = callloginserver (); / / access to the login server if (! empty ($info)) / / login succeeded} / / if the user does not log in, log in in this system and call the login server interface function login () / / normal login {. / / verify the validity of the user $_ session ['uid'] = $user_id Setcookie ('sign', encrypt ($pass9),','/', 'the.com');}

First check whether the user is logged in to the login system

Funtion sign () {$sign = $_ cookie ['sign']; if (! empty ($sign)) {$sign = decrypt ($sign);. / / login success}}

If the user is not logged in, log in to the system and call the login server interface

Function loging () / / log in to the system {. / / login succeeded callseverlogin (); / / notify the user to log in}

All sites share a login system; when the user logs in successfully at one of the sites, the system calls the login interface of the other site, completes the login of the user at the other site, and sets the corresponding login information at the same time; or when the user logs in, only the user login information is saved in the system, and when the user logs in in other sites, the system interface must be requested to obtain information about whether the user is logged in. The disadvantage of the former approach is that those sites need to save user state regardless of whether the user uses other sites or not, while the latter shifts all the pressure to the login system. If you want to realize the unified operation of user exit, you need the site to call the login system exit interface, and then the login system interface to call the exit interface of other sites; or set a mark, if the tag does not exist, indicate the user to exit, at this time, as long as the sign is cleared, other sites will know that the user has exited the system when they find that the sign does not exist.

This way of handling requires specifying a login interface and a logout interface between the login system and each site. Through these interfaces, each site can easily handle user login or logout.

This is the end of the content of "how to solve the failure of multi-domain name login in web system in php". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report