尝试在域和子域cakephp之间共享会话(会话不断重置)

I have similar problem and I've tried every option that has been mentioned so far, I guess there must still be something I'm not doing right because this is just not working for me. Here's what I have and what I've noticed so far - I have a website say (example.com) and a sub-domain (user.example.com). The idea is a user should be able to login from the top domain and not have to login again when s/he goes to any of the sub-domain. Here's my host layout

www/ app/ Controllers/

Model/

Views/

web_root/

sub_domain_root/ Controllers/

Model/

Views/

web_root/

lib/ Cake/*

What happens is this, when I login on the top-domain and go to the sub-domain I can't seem to pick up the user session in the sub-domain. Things get even wilder when I go back to the top-domain from the sub-domain I seem to have lost the user session because even the top-domain can't seem to find it anymore. I suspect that because the two domains are using the same core and when the user navigate to another domain (like the sub) Cake/php sees it as a fresh request to the domain. Please help, this problem is holding me back on my schedule.

Your problem is linked to the session.cookie_domain directive. You can probably set it through an ini_set directive

Unfortunately, I don't have time to check right now if you should have .example.com or example.com in it (it's different for Javascript & PHP)

I had the same problem. Try setting Configure::write('Security.level', 'low'); in core.php. I remember needing to dig into the security level stuff to figure it out. When it is set to high The security code kept resetting the sessions on me without my knowledge.