2

I am using this link to use the cookies functionality in yii framework. When I accessed the application in localhost it gives following error:

Property CWebApplication.Cookies is not defined.

Please help me guys that where I am doing mistake.

I have included

'Cookies' => array ( 'class' => 'application.components.CookiesHelper' ),

in config->main.php and i am trying to use the function putCMsg as follows

$this->putCMsg('someCookieName','SomeValue');

But this error comes on this line of index.php

Yii::createWebApplication($config)->run();

Tausif Anwar
  • 1,237
  • 1
  • 10
  • 21

1 Answers1

0

Creating cookie in config/main.php is not a good solution. It's better to set cookie in the controller's action like this:

$cookie = new CHttpCookie('someCookieName','SomeValue');
$cookie->expire = 200000; //times in milliseconds    
hamed
  • 7,939
  • 15
  • 60
  • 114
  • Thanks for your reply adding any component as an array doesn't mean that i am creating object of that class. It simply means that i am saying that just go to this package to pick something. I am comfortable to use the way you have mentioned in your answer but i want to use by declaring it into component folder or helper folder as discussed in the link i have mentioned in my question Thanks. – Tausif Anwar Mar 17 '15 at 10:21