Home Backend Development PHP Tutorial 两个网站数据同步与登录的有关问题(CSDN如何做的?)

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

Jun 13, 2016 pm 01:47 PM
cookie php sso

两个网站数据同步与登录的问题(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 of this Website
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

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

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

7 PHP Functions I Regret I Didn't Know Before 7 PHP Functions I Regret I Didn't Know Before Nov 13, 2024 am 09:42 AM

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

See all articles