I'm using Yii framework.
I set a cookie as you can see blow , it was working in localhost but stop working after I uploaded my web app on online host. I'm getting this error:
Cannot modify header information - headers already sent by (output started at <path to webapp>/protected/components/Controller.php:1)

Code:

PHP Code:
class Controller extends CController
{
   public function 
changeLanguage()
        {
            if(isset(
$_GET['language']) && $_GET['language']=='fa'){
                
            
$cookie = new CHttpCookie('language','fa_ir');
                    
$cookie->expire time()+60*30;
                    
Yii::app()->request->cookies['language'] = $cookie
How can I set a cookie in header? Why it was working on localhost?