Home  >  Article  >  Backend Development  >  php单点登录

php单点登录

WBOY
WBOYOriginal
2016-06-06 20:25:371323browse

一个商城一个论坛系统,怎么实现单点登录?在商城中成功登录点击一个按钮就会登录进入到论坛系统中。

回复内容:

一个商城一个论坛系统,怎么实现单点登录?在商城中成功登录点击一个按钮就会登录进入到论坛系统中。

可以看下Ucenter,或许可以实现你的需求。

若在同一个服务器可以设置session共享,
ini_set('session.cookie_domain', '.domain.com');

两个系统在一个域名下的话,可以将登陆凭证写cookie,这样不管登陆那个都可以将cookie里的登陆信息带过去。

不在一个域名下的话,可以在跳转的时候从当前系统取出登陆信息(token之类的)一并带过去,第二个系统可以根据token做校验,这样两个系统需要共用一套登陆校验机制。

提主可以参照一下CAS的思路.

原来考虑过,没具体实施,仅供参考:

  • 统一登录

    • 各app登录时跳转到 http://auth.abc.com/login 页面;

    • 用户成功登录后,在 auth.abc.com domain 下设置 cookie(当然可以设置服务端缓存): auth_uid & auth_sign;

    • auth_sign 规则: md5(auth_uid + 混淆码);

  • 自动登录

    • 各app需要校验登录的链接,在拦截器判断是否有登录过的信息,若存在,校验登录信息和签名;没有的话通过auth跳转,附带app_name,比如
      (http://auth.abc.com/verify?redirect_url=.....)

    • auth校验auth_uid和auth_sign cookie,失败后跳转到登录界面,成功后跳转到redirect_url并附带 user_id 和 auth_ticket

    • auth_ticket 生成要根据 user_id 和 auth_key(app和auth中都保存)生成,用于app校验是否有效

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