Yii 怎么实现登录后跳转到二级域名

WBOY
Release: 2016-06-13 10:56:52
Original
947 people have browsed it

Yii 如何实现登录后跳转到二级域名?
我想实现的功能是:用户从www.domain.com登录后自动跳转到user.domain.com,
我用字符串拼接的方法实现了页面跳转(不知是否有更好的方法?)
目前问题是,页面跳转后用户的登录状态无效了,需要重新登录.
向各位大虾求解决办法.

------解决方案--------------------
没用过yii,不过你登陆后无效说明你cookie保存的域不对,应该是 .domain.com
------解决方案--------------------
php跨域共享session
http://blog.sina.com.cn/s/blog_4b64149a01000780.html
------解决方案--------------------
可以在配置文件(一般是main.php)里,配置一下user组件:

PHP code
'user'=>array(            // 启用基于cookie的认证            'allowAutoLogin'=>true,                        'returnUrl'=>'user.domain.com'        ),<br><font color="#e78608">------解决方案--------------------</font><br>
Copy after login
PHP code
<?phpini_set ('session.cookie_domain', '.domain.com');?><br><font color="#e78608">------解决方案--------------------</font><br>登陆信息跨域了就取不到,你要解决这个跨域问题才行<br><font color="#e78608">------解决方案--------------------</font><br>每个cookie字串都属于一个域,如果www.domain.com里面设置的cookie,在user.domain.com里面肯定读不了。<br><br>但是你可以设成 *.domain.com,这样主域名和二级域名都是符合的,就实现了cookie共享。<div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!