在CakePHP中在网站上维护两个不同域之间的会话时出现问题 [英] Problem in maintaining session between two different domains on a website done in CakePHP

查看:113
本文介绍了在CakePHP中在网站上维护两个不同域之间的会话时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如我之前发布的...我已经创建了一个两种语言的网站。一个与URL www.mainDomain.com (英语)和其他 www.fr.subDomain.com (法语) 。



两者都是在CakePHP中完成的,在法语中我刚刚把它的意见更改为法语。但问题是,当任何人登录的英文版,然后切换到法语版本,会话不能识别它,并要求再次登录。



因为这一点,Swanny告诉我要经历链接,我做了我的应用程序,因为它在链接上说。显然,它工作在登录,共享两个域之间的会话(主域及其子域)。但是当我彻底检查它,我认识到,这两个网站都抛出最新的新闻从数据库,两个数据是不同的。只是为了检查如果我错了我改变了一些保存变量到数据库在会话数组。但现在它拒绝记住任何东西(会话)。任何人都可以建议我这个问题,如何解决这个问题...



提前感谢

解决方案

我不确定我是否完全理解,但我会尝试。我认为这是关于一个PHP设置 session.cookie_domain



假设您的网站有以下URL: / p>



您想要的设置是: .example.org p>

您可以在 php.ini .htaccess 文件,甚至是PHP本身:

 <?php ini_set('session.cookie_domain','.example.org' ); ?> 

如果您的网站在两个完全不同的网域上运行,例如:





...则无法在这两个不同的域之间共享cookie。


Well as I have posted earlier too...I have created a site in two languages. One with URL www.mainDomain.com (English) and other with www.fr.subDomain.com (French).

Both are done in CakePHP,in french I have just changed the views of it to French. But the problem is, when anybody login's in English version and then switches to the French version, the session doesn't recognizes it and ask for login again. It has become to be the biggest bug in the Web application which I have done till far.

For that, as Swanny told me to go through a link and I did it on my application as it was said on the link.Apparently,it worked for login which shared session between two domains(main domain and it's subdomain). But when I checked it thoroughly, I recognized that both the sites are throwing the latest NEWS from Database, both data are different. Just to check if I was wrong I changed the some save variable to database in session array. But now it refused to remember anything (session). Could anyone suggest me what could be problem with this and how can I resolve this...???

Thanks in advance

解决方案

I'm not sure I completely understand, but I'm gonna try. I think this is about a PHP setting called session.cookie_domain.

Assuming your websites have the following URLs:

The setting you want is: .example.org.

You can adjust this in php.ini, a .htaccess file or even in PHP itself:

<?php ini_set('session.cookie_domain', '.example.org'); ?>

If your websites run on two completely different domains, e.g.:

... then there is no way to share the cookie between these two different domains.

这篇关于在CakePHP中在网站上维护两个不同域之间的会话时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆