search
HomeBackend DevelopmentPHP Tutorial两个网站数据同步与登录的有关问题(CSDN如何做的?)

两个网站数据同步与登录的问题(CSDN怎么做的?)
hi
项目中遇到一个问题,想听听各位的思路

有两个网站,一个是用asp.net开发的,数据库是mssql
另外一个是用php,数据库是mysql, 现在需要做到:

两个网站的用户数据同步,即在任何一个网站上注册,在另外一个网站上都可以登录,除了登录信息要同步以外,还需要同步积分,即在两个网站上搞一些行为,都可以获得积分,两个网站上都可以花这些积分

两个网站部署在同一个机房,web服务器可以高速的访问db server, 两个网站用的是同一个域名的不同的子域名,想问问有什么思路让这两个网站同步,如何实现single sign on,有没有什么比较成熟的做法或者框架可以选用?

另外:1 “两个站”是不跨domain的~~ 2 我也想问问CSDN是怎么与uchome整合的?

谢谢

------解决方案--------------------
你给的分有点少啊!


关于你说的效果!有多种实现方式!

1.webservice

2.共用一部分数据库数据(反正一机房)

3.xxxx方式
------解决方案--------------------
用ucenter要求你要有一个asp的解密协议同php的一样的。

其他的都较容易。

由ucenter分发登录信息并同步。


如果你用web服务,这个可能只能是被动的吧。退出不同步吧。

被动式的,需要检查时去webserver去查一下有没有登录或退出。如果有,则,认为登录。 这个需要程序经常或在有必要时,要检查webserver. 如果一应用退出,除非另一程序检查,否则他不会退出。




------解决方案--------------------
可以通过共享SESSION的方式来实现:

看UCENTER同步机制谈SSO

先说说SSO(单点登录),它的大致原理是所以站点会有一个公用的用户认证 系统,所有的登录登出都由此系统来处理。我们可以将其理解成站点C,现在有A B两个站 点需要同步,在用户访问A的时候,A先去访问C,看用户是否已在C有登记,没有的话直接 跳转到C去登录,成功后跳转到A,并且在A上存了一个COOKIE来保留用户信息。此时A登录 成功。当用户再去访问B站点的时候,系统将会把COOKIE的值一同返给认证服务器,验证其 是否合法,如果合法的话,认定用户已登录,无需重新登录,如果有更多站点的话,道理 相同,这样就实现了多个站点同步功能。(这里每个站点的用户会话机制可以不同,我们 可以根据认证端返回的信息使每个站点构建自己应用的会话信息。)

所以为了 完成一个简单的SSO的功能,需要两个部分的合作:
1、统一的身份认证服务。 
2、修改Web应用,使得每个应用都通过这个统一的认证服务来进行身份效验。 

再说说UCENTER,提到这个,用过康盛产品的人肯定很熟悉,就是它将康盛的 多个产品联系到了一起,DISCUZ、SUPESITE、UCHOME等等,都可以通过它做到用户同步。 前面的一篇文章《UCenter跨域、单点登陆机制分析》

http://www.trindo.cn/? action=show&id=60已经大致分析过其实现机制,主要还是登录登出任何一个站点 的时候,去批量处理所有存在于UCENTER中的站点列表,实现其同步的原理。

看到这里,我们可以发现其实UCENTER就是一个简单的SSO。但是其具有局限性,当需要同 步站点多的时候,UCENTER处理起来会很吃力(这点很多网友应该深有体会)。而如果我们 采用普通的处理机制,无论有多少个站点,根本不受影响。因为只有我们用到某个站点的 时候,此站点才会与认证系统互动,不会浪费资源。

前段时间做了一个项目就 遇到了一个JSP站点与PHP站点同步的需求,这里我就用到了一个同步PHP文件,此文件的主 要用途在于一个PHP与JSP加密解密通用函数encrypt,decrypt。认证系统是用JSP编写的。 这个PHP同步文件包含在用户需要登录的地方,当用户访问此页面时,(如果已在主站登录 )系统会将本地存在的COOKIE信息抛给认证系统,经过认证处理后,如果正确则返回用户 名,在PHP这边就可以根据用户名来处理这边的会话机制,达到登录的目的,如果认证失败 ,则直接跳转到认证系统进行认证。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
The Continued Use of PHP: Reasons for Its EnduranceThe Continued Use of PHP: Reasons for Its EnduranceApr 19, 2025 am 12:23 AM

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python: Exploring Their Similarities and DifferencesPHP and Python: Exploring Their Similarities and DifferencesApr 19, 2025 am 12:21 AM

PHP and Python are both high-level programming languages ​​that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP and Python: Different Paradigms ExplainedPHP and Python: Different Paradigms ExplainedApr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP and Python: A Deep Dive into Their HistoryPHP and Python: A Deep Dive into Their HistoryApr 18, 2025 am 12:25 AM

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

Choosing Between PHP and Python: A GuideChoosing Between PHP and Python: A GuideApr 18, 2025 am 12:24 AM

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP and Frameworks: Modernizing the LanguagePHP and Frameworks: Modernizing the LanguageApr 18, 2025 am 12:14 AM

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHP's Impact: Web Development and BeyondPHP's Impact: Web Development and BeyondApr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

How does PHP type hinting work, including scalar types, return types, union types, and nullable types?How does PHP type hinting work, including scalar types, return types, union types, and nullable types?Apr 17, 2025 am 12:25 AM

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values ​​and handle functions that may return null values.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.