Session cannot be started headers sent

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, &lt;%= Yii::app()-&gt;user-&gt;name %&gt;!

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 !

That's a good catch. We should enable output caching to avoid such error.

Could you please create a ticket? Thanks.

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

thanks

nz

Is this fix included in beta?

Nope, the fix was checked in after the beta release…

So I should use SVN to have it?

yes.