Thought this might be useful to someone… I modified my WebUser class to contain some methods for handling cookie manipulation similar to how flash messages are handled.
public function hasCookie($name)
{
return !empty(Yii::app()->request->cookies[$name]->value);
}
public function getCookie($name)
{
return Yii::app()->request->cookies[$name]->value;
}
public function setCookie($name, $value)
{
$cookie = new CHttpCookie($name,$value);
Yii::app()->request->cookies[$name] = $cookie;
}
public function removeCookie($name)
{
unset(Yii::app()->request->cookies[$name]);
}
Another bit of a development, including some human-friendly time handling from 3ft9.com. (I can’t link as it’s my first post, but do a search for “snippet-cookie-class-for-php”)
I’ve also added in a couple of lines to allow path and domain management using Yii app params. Obviously change to what suits or remove if you want.