请教一个问题,要实现多个二级域名同时登录,应该如何配置呢?

现在有三个域名:

www.test.com

a.test.com

b.test.com

user.test.com

在user.test.com下面登录后如何让www.test.coma.test.com、b.test.com同时保存登录状态呢?

网上有帖子说配置components中的user和session,设置结果如下:

‘user’=>array(

        'identityCookie'=>array('domain'=>'.test.com','path'=>'/'),


        'allowAutoLogin' => true,


    ),

‘session’=>array(

        'cookieParams' => array('domain'=>'.test.com','lifetime' => 0),


        'timeout' => 3600,


    ),

但是我配置之后必须要在登录的时候勾选“记住密码”才能登录成功,否则都登录失败。请高手赐教!

先声明,不是高手。

这是一个比较典型的Single Sign-on (SSO)问题。

比较好的解决方法是使用Centralized Authentication Server. 这样你的用户验证可以做到Application一级。安全性较高,但需要后台服务和数据库支持。

你的方法是使用Cookie的方法,我没有试过,不过你可以让系统强制记住密码。搜索$this->rememberMe相关的代码并修改。