Currently I'm struggling a bit with setting cookies. I've tried several ways, but I'm stuck at the moment. Perhaps someone can shed some light here…
I tried the following:
$cookies['lang'] = new CHttpCookie('lang', $_GET['lang']); After that (among other less likely ways): Yii::app()->request->cookies['lang'] = new CHttpCookie('lang', $_GET['lang']); Also: $cookies = Yii::app()->request->getCookies(); $cookie = new CHttpCookie('lang', $_GET['lang']); $cookies['lang']->add('lang', $cookie)
But no cookie…
Trying to figure out why, So looking at CCookieCollection->add() I put an additional throw in.
if($this->_initialized) $this->addCookie($cookie); else throw new CException(Yii::t('yii','CCookieCollection not initialized.'));
And yes I get that exception. So it seems its not initialized. Not sure where to look anymore…