Cookie fails to save

I hate to ask dumb questions, but i can’t to figure this one by myself :blink:

The thing is - application won’t store a cookie if it has an ‘expire’ property set.

The code i’m workin’ on is quite simple and yet - not working. Is it some kind of Yii bug?




$cName = '1_2vf';

$valueSet = 'test';

$cookieSet=new CHttpCookie($cName,$valueSet);


$a=intval($this->determineCookieLifetime()); // returns valid future timestamp, but anyway - "$a=time();" doesn't work either

		

$cookieSet->expire = $a;

Yii::app()->request->cookies[$cName]=$cookieSet;

exit;

That piece of code won’t send any cookies to client browser, but it it works just fine if no ‘expire’ property is set - but this is not something i can bear with because cookie will be gone as soon as browser session is closed.

Help me, please!

What is the code of determineCookieLifetime()…

Fot the cookie duration you should use time() + time duration

for example 1 day is time() + 86400 (24 hours * 60 minutes * 60 seconds)

Thank you! It actually was that i forgot to add time() to my timestamp calculations. Well, it’s always a bad idea to code for 6-7 hours straight :) Thanks! B)

You’re welcome!