Yii Framework Forum: Session cannot be started headers sent - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

Session cannot be started headers sent Rate Topic: -----

#1 User is offline   notzippy 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 201
  • Joined: 06-October 08

Posted 24 October 2008 - 10:18 AM

Hi

So I was trying ajax with the demo application, for testing purposes.
So I added this to the view/site/index.php

<%= CHtml::ajaxLink("Click me","array('site/updateTarget'),array('update'=>'.target')) %>
<div class="target">Target</div>

Then in the site controller

public function ActionUpdateTarget() {
    $this->renderPartial('index');
}

Clicking the link on the page then renders this error (in the target area)

#0 /home/yiiframework/web/CHttpSession.php(96): session_start()
#1 /home/yiiframework/web/CHttpSession.php(83): CHttpSession->open()
#2 /home/yiiframework/core/CApplication.php(712): CHttpSession->init()
#3 /home/yiiframework/web/CWebApplication.php(216): CWebApplication->getComponent()
#4 /home/yiiframework/web/auth/CWebUser.php(83): CWebApplication->getSession()
#5 /home/yiiframework/core/CApplication.php(712): WebUser->init()
#6 /home/yiiframework/core/CApplication.php(134): CWebApplication->getComponent()
#7 /home/public_html/cart/protected/runtime/views/ba4c96d0/index.php(3): CWebApplication->__get()
#8 /home/yiiframework/web/CBaseController.php(123): require()

The error is caused by this line
Welcome, <%= Yii::app()->user->name %>!
The "welcome" gets sent then the session is attempted to be initialized. I could manually force the session to start before the view begins to render but shouldn't yii take care of this ? Or am I doing something wrong here ?

Thanks
nz

btw : wow, easy ajax !
0

#2 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,879
  • Joined: 04-October 08
  • Location:DC, USA

Posted 24 October 2008 - 10:36 AM

That's a good catch. We should enable output caching to avoid such error.
Could you please create a ticket? Thanks.
0

#3 User is offline   notzippy 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 201
  • Joined: 06-October 08

Posted 24 October 2008 - 10:43 AM

Created issue 18 http://code.google.c...es/detail?id=18


thanks
nz
0

#4 User is offline   KJedi 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 381
  • Joined: 19-October 08
  • Location:Nikolaev, Ukraine (Europe)

Posted 27 October 2008 - 03:34 AM

Is this fix included in beta?
0

#5 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,879
  • Joined: 04-October 08
  • Location:DC, USA

Posted 27 October 2008 - 06:07 AM

Nope, the fix was checked in after the beta release...
0

#6 User is offline   KJedi 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 381
  • Joined: 19-October 08
  • Location:Nikolaev, Ukraine (Europe)

Posted 27 October 2008 - 11:34 AM

So I should use SVN to have it?
0

#7 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,879
  • Joined: 04-October 08
  • Location:DC, USA

Posted 27 October 2008 - 11:37 AM

yes.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users