Background: I’m new to CakePHP. I have a small test site (mostly composted of static views and a contact form at the moment) to play with while I learn. Everything worked fine on localhost (Apache on Ubuntu) so I deployed it to a shared hosting account (provided by Lunarpages). I moved the /cake folder out of the normal directory structure (so I could use it for multiple apps) and I reconfigured my webroot’s index.php paths accordingly.
Problems:
-
setFlashmessages do not get displayed. Even making a simple view that does nothing other than$this->Session->setFlash('message');. I don’t get any error message, the flash just doesn’t get displayed -
Redirects don’t work. For instance, after the contact form is completed I want to
$this->redirect( array( 'action' => 'success' ), null, true);but the server throws an error:Warning (2): Cannot modify header information – headers already sent by (output started at /routetoapp/config/routes.php:40) [CORE/cake/libs/controller/controller.php, line 742]
Everything else seems to work just as it did on localhost – URL rewriting, component loading, model validation. I don’t know if my problems are related or separate issues
Troubleshooting so far:
- I’ve tried both ‘cake’ and ‘php’ for
Configure::write('Session.save', 'val');but neither made a difference. - My app/tmp folder is writeable.
- My layout template has the correct code for displaying flash messages. (The exact same M, V, C, and Layout objects display the expected flash on localhost)
I assume I’m missing something simple, but I’m new to this framework so I’m not sure where else to look.
See Matt Huggins answer for your flash problem. That’s correct
As for your redirect issue,
you might have an extra space or something in your
routes.phpfile. Make sure there are no spaces before the starting<?phptag and remove the closing?>