May 122010
 

Preface

I have yet to run across anyone in the Google search result world that is running a CakePHP application that contains multiple sub-applications. I have been developing multiple web-based applications in CakePHP that all reside in a single virtual host. The “master” application controls access to these applications. Each application is a sub-directory of the master APP/webroot (actually contains symlinks pointing back to the applications’ APP/webroot and Apache +FollowSymLinks).

Problem

My Session->flash notices do not work when I call a redirect within these sub-applications. If I do NOT redirect, then the flash appears as expected. The moment I redirect, it’s gone.

Solution

I went through a lot of “solutions” according to people experiencing the similar problems. In doing so, I noticed that I had all the Session.cookie parameters configured the same in every APP/config/core.php file.

Configure::write('Session.cookie', 'CAKEPHP');

I changed this for one of my sub-applications to something unique. Voila! It worked. I have not gone into the details as to why, but it seems apparent to me that the Session.cookie must be unique across the “master” application and any sub-applications residing within the “master” app. This allows individual session cookies to be started for each application to use/access. The “master” app is probably wiping the slate clean behind the scenes.

Configure::write('Session.cookie', 'APP_NAME');