Tuesday, February 3, 2009

Re: Cannot modify header information - headers already sent by

Ok, I removed the php close tag from all the models and controllers
but that didnt work.

Here is the full error message I am getting:

=====================================================
Warning (2): Cannot modify header information - headers already sent
by (output started at /home/user/public_html/sub/index.php:2) [CORE/
cake/libs/controller/controller.php, line 615]

Code | Context


header - [internal], line ??
Controller::header() - CORE/cake/libs/controller/controller.php, line
615
Controller::redirect() - CORE/cake/libs/controller/controller.php,
line 596
AppController::checkAdminSession() - APP/app_controller.php, line 40
SalesController::beforeFilter() - APP/controllers/
sales_controller.php, line 17
Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 226
Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 211
[main] - CORE/public_html/sub/index.php, line 92
=====================================================

Any ideas?


On Feb 3, 7:54 am, AD7six <andydawso...@gmail.com> wrote:
> On Feb 3, 7:45 am, gkc <gerardkco...@gmail.com> wrote:
>
>
>
> > I have researched this problem and have already removed any blank
> > space after the closing php tag.
>
> > Here is the controller code:
>
> >    function beforeFilter() {
> >                 if(isset($this->params['admin'])) {
> >                         $this->checkAdminSession();
> >                         $allowed = array('Sales','Admin');
> >                         $role = $this->readSession('role');
> >                         if(!in_array($role,$allowed)) {
> >                                 $this->roleRedirect();
> >                         } else {
> >                                 $this->layout = $role;
> >                         }
> >                 }
> >         }
>
> > Here is the appcontroller code:
>
> >         function checkAdminSession() {
> >                 if (!$this->Session->check('User')) {
> >                         $this -> redirect('/users/login', null, true);
> >                         exit();
> >                 }
> >         }
>
> >         function readSession($val) {
> >                 if ($this->Session->check('User')) {
> >                         return $this->Session->read('User.' . $val);
> >                 }
> >         }
> >         function roleRedirect() {
> >                 switch($this->readSession('role')) {
> >                         case 'Admin':
> >                                 $this->redirect('/admin/users/' .'' , null, true);
> >                                 exit();
> >                                 break;
> >                         case 'User':
> >                                 $this->redirect('/admin/users/', null, true);
> >                                 exit();
> >                                 break;
> >                         case 'Sales':
> >                                 $this->redirect('/admin/sales/', null, true);
> >                                 exit();
> >                                 break;
> >                 }
> >         }
>
> > I should also mention that the webroot folder is in a subdirectory of
> > the public_html (/home/user/public_html/sub/)and I have the cake and
> > app directories in the root (/home/user/) with the webroots index.php
> > properly edited to reflect the various directory paths.
>
> > If I comment out the beforeFilter in the controller everything is
> > fine, but if I leave it in then I get the header information error.
>
> > Again, I have already removed all the extra whitespace from the end of
> > all models, controllers, and views.
>
> > Any help would be greatl appreciated.
>
> Try reading the error message. It tells you the file and line that you
> should then focus your efforts on.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: